smash
I certainly like a code obfuscation and golfing: the recent example includes this and this. The today’s project is more like the former, where very short code takes much time to explain. Without further ado, here it is:
This little program reads a spelt number from the standard input and writes the corresponding number to the standard output. It supports numbers up to 1015-1 and still weighs only 256 bytes of C. (There is also a shorter version that can handle up to 19,999,999 and does not use
long long.) The input should be correct, although it will handle “a” and “and” correctly and ignore some invalid words.It assumes the ASCII character set and 2’s complement representation, and requires
intandlong longto be at least 32 and 64 bits long, but that’s all they expect from the compiler. For example, it does not matter whethercharis signed or unsigned, EOF does not have to be -1, and so on. (Yes, I did keep in mind while writing this program.)While I left the explanation of the BF interpreter as a reader’s exercise, in this time I’ll give a detailed explanation of the program. Keep in mind that there are two versions of the program; the explanation is primarily for the longer version.
BREAKING: Alleged LHC Memo Hints Scientists Have Found the Elusive Higgs Boson
uh WHAAAAAAAAAAAAAAAAAT?!?
C.G. Jung, from the Red Book
Original (without tumblr limitations)