eurica

numbers for people.

Make words with JavaScript brackets

Since I work for one of the nerdiest places on earth I wasn’t surprised when our sales team started sending me messages as Brainfuck programs.

-[--->+<]>++++.[->++++<]>+.[--->+<]>----.-[++>---<]>+.------------.---[->++++<]>-.++++[->+++<]>.+++++++++++++.---------.++++++.++++++.--.-------.-[--->+<]>.-[-->+++++<]>++.

But who has a Brainfuck compiler handy? Everyone has a JavaScript interpreter… maybe I can use that. I seem to remember JavaScript plays fast and loose with types, for instance [![]]+[][[]]+[!![]]

And we can make numbers just as painfully: +[] and +!+[]. So we can pluck letters out of those words, like we can pull an “r” out of “true”: (!![]+[])[+!+[]]. (I can also get a capital N out of (+!+[])/(+!+[]+!+[])[+!+[]]

Ok, there’s a lot of vowels in there, I wonder how close we are:

grep -i '^[falseundefinedtrue]*$' /usr/share/dict/words | wc -w
8800

Cool, we can make almost 9000 words. That sounds like a lot, but I don’t know how many are in the OS X words file.

wc -w /usr/share/dict/words
235886

Oh. Out of 235886, that’s barely 3.3%. That’s a little disappointing. But we can get creative, 0 is the only vowel missing.

grep -i '^[falseundefinedtrueo]*$' /usr/share/dict/words | wc -w
15075

Ok 6.4%, what if we stretch things a bit further with 2=Z, 3=B, 6=G… Hmm 33049 words. 14%, come on english language, you’re killing me here. (Sadly, the stats don’t seem much better even for Hawaiian)

Well, how close can we get with these? How important are “..c….h.jk.m..pq….vwxy.”?

grep -i '^[falseundefinedtrueozbg]*$' /usr/share/dict/words | wc -w
15075

Ok, what if I can bring spacing back? Adding a / symbol still looks cool enough +!+[]/(+!+[]+!+[])+[+[]] has a dot. And after a few manual tweaks, we still have a string that needs some decoding:

  • 1..sauu..tne..3est..nninds..0f..nnie..9enerati0n..destr0ieed..3ie..nnadness..staruin9..niesterieal
  • tesla..started..uu0rfin9..in..tne..tele7n0nie..and..eleetrieal..fields..3ef0re..innnni9ratin9..t0..tne..united..5tates..in..1884..t0..uu0rf..f0r..tn0nnas..edis0n.
  • d0..ie0u..life..9reen..e99s..and..nann..1..d0..n0t..life..tnenn..5ann1ann.

That’s kind of totally readable! And now the moment you’ve all been waiting for: Let’s turn it into []+/!()‘s

Give me a string:

Cool, eh?
((![]+[])[+!+[]])+(((+!+[])/(+!+[]+!+[])+[])[+!+[]])+(((+!+[])/(+!+[]+!+[])+[])[+!+[]])+((![]+[])[+!+[]+!+[]])+(([][[]]+[])[+!+[]+!+[]+!+[]+!+[]+!+[]])+((!![]+[])[+[]])+((!![]+[])[+[]])+((![]+[])[+!+[]+!+[]])+((!![]+[])[+!+[]+!+[]+!+[]])