My sister posed a game involving emojis. Given a word, represent it with emojis without using the emoji that directly indicates the word. E.g. the solution for "cat" can't include "๐". Since it's my sister's game, I dubbed it Kaley Encoding.
The rules are simple and vague enough to allow for creativity and some amusement. There's no single correct solution for every input; I could use the emojis for ears, eyes, and a tongue to represent a dog (my sister claimed it was a horse).
This program takes a single word as input and outputs a solution. If it can't find a solution, it fails.
This solution compares the input to the names of emojis (e.g. "๐" is cat
and "๐" is dog
), finds the longest sequence of matching characters, and records the emoji-count pairing. The result is a sequence of emojis where the count indicates how many characters from the name can be read. The count is given by the color of the heart: no heart means one letter, a red heart means two, orange means three, etc. How can we remember what the colors mean? ROY G BIVโwhere red means two.
I chose hearts because the world could always use a little more love and kindness when communicating.
$ goober --reference -i cat
Reference:
๐ต cactus
๐ฆ t-rex
Result:
๐ตโค๏ธ๐ฆ
The encoding for "cat" is a cactus emoji followed by a red heart and a t-rex. The red heart indicates we use two letters from the preceding emoji while no heart following the t-rex means only use one letter. Using the reference, the result is "ca" from cactus and "t" from t-rex. Cat!
This works for nonsensical inputs (NB some emojis appear wide):
$ goober --reference -i asdf
Reference:
๐งโ๐ astronaut
๐ก๏ธ dagger
๐ญ factory
Result:
๐งโ๐โค๏ธ๐ก๏ธ๐ญ
As well as more complex inputs:
$ goober --reference -i supercalifragilisticexpialidocious
Reference:
๐ฆธ superhero
๐
calendar
๐ง ice
๐ธ frog
๐งฎ abacus
๐ฆ giraffe
โ libra
๐๏ธ stadium
๐ง ice
๐ฉป x-ray
โ๏ธ pick
๐ฝ alien
๐ฆค dodo
๐ฌ cigarette
๐ octopus
โ๏ธ umbrella
โ sagittarius
Result:
๐ฆธ๐๐
๐งก๐ง๐ธโค๏ธ๐งฎ๐ฆโค๏ธโโค๏ธ๐๏ธโค๏ธ๐ง๐งก๐ฉปโ๏ธโค๏ธ๐ฝ๐งก๐ฆคโค๏ธ๐ฌโค๏ธ๐โ๏ธโ
If an emoji can't be found for even a single character, the program will fail:
$ goober --reference -i asdfqwerty
panicked at 'No sequence available'
Nope.