Skip to content

Instantly share code, notes, and snippets.

// Add a hole to the top of the jellyfish to attach to a keychain.
keychain = true;
// The number of tentacles segments that drop down the jellyfish. Increasing its number will increase the jellyfish size.
tentacles = 3; // [3:5]
// Select the mouth style.
mouth = 1; // [0:no mouth, 1:happy mouth, 2:sad mouth, 3:cute mouth]
// Select right eye style.
@queimadus
queimadus / encoder.scala
Created February 29, 2020 01:56
Chuck Norris Unary Code Binary Encoder
def encodeBinaryString(s: String) = {
s.foldLeft(List.empty[List[Char]]) {
case (List(), cur) => List(List(cur))
case ((head @ h :: _) :: tail, cur) if cur == h => (cur :: head) :: tail
case (acc, cur) => List(cur) :: acc
}.map {
case l @ '1' :: _ => "0 " + "0" * l.size
case l @ '0' :: _ => "00 " + "0" * l.size
}.mkString(" ")
}