And to run this program in a <i>single line of bash</i> on Unix systems (does create a ./a.out file):<p><pre><code> echo 'int main(){int _[2048],O=(int)&O,__=~__+__;while((__=-~__)^2048)__[_]=(O=(O*0x41C64E6D+12345)&0x7fffffff)&1024?1<<5:0;while(usleep('"'"'d'"'"'<<'"'"'\n'"'"'),__+=~__){while((__=-~__)^8192){if(_[((__>>2)+2048+"\x01?@A"[__%4])%04000]&1<<5)*(_+(__>>2))=-~_[__>>2];if(_[((__>>2)+04000-"\x01?@A"[__%4])%2048]&1<<5)*(_+(__>>2))=-~_[__>>2];if(__%4==3)_[__>>2]|=_[__>>2]^'"'"'\"'"'"'&&_[__>>2]^'"'"'#'"'"'?((_[__>>2]^3)?0:1<<4):1<<4;};while((__=-~__)^10240)if(putchar((_[__%2048]=_[__%2048]<<1&1<<5)?'"'"'X'"'"':'"'"' '"'"'),!(63^__%0100))putchar(10);}};' | gcc -xc - && ./a.out
.</code></pre>
Nice explanation of each line is here:<p><a href="https://github.com/duckythescientist/obfuscatedLife/blob/master/remarks.md" rel="nofollow">https://github.com/duckythescientist/obfuscatedLife/blob/mas...</a><p>Code is obfuscated more than needed to run. It starts with something simple like this:<p>"I abuse 2's complement math to initialize it as -1"<p>Instead of: __ = -1
The code reads: __=~__+__<p>... and then gets more and more bizarre.
I'm sure many would complain about the obfuscated nature of the code. I however find it strangly beautiful. It has the appearance of a strand of DNA and then one marvels at all of the complexity hidden in these cryptic lines.<p>To see it:<p>`git clone <a href="https://github.com/duckythescientist/obfuscatedLife.git" rel="nofollow">https://github.com/duckythescientist/obfuscatedLife.git</a><p>cd obfuscatedLife<p>gcc life.c<p>./a.out`<p>Here is a screenshot[1] for anyone who didn't run the code. However a screenshot hardly does the dynamic nature of it justice.<p>[1] <a href="http://imgur.com/hWzEWAe" rel="nofollow">http://imgur.com/hWzEWAe</a>
Youtube link for those who are unwilling or unable to download and compile yourself:<p><a href="http://www.youtube.com/watch?v=LFx46bAq-_E" rel="nofollow">http://www.youtube.com/watch?v=LFx46bAq-_E</a><p>As well, for those that don't want to use youtube, you can view/stream the raw video here:<p><a href="http://lelandbatey.com/files/Obfuscated%20C%20-%20Game%20Of%20Life-LFx46bAq-_E.mp4" rel="nofollow">http://lelandbatey.com/files/Obfuscated%20C%20-%20Game%20Of%...</a>
Fun obfuscated version in ruby.<p><a href="https://github.com/stefanpenner/obfcuscatedLife.rb/blob/master/game_of_life.rb" rel="nofollow">https://github.com/stefanpenner/obfcuscatedLife.rb/blob/mast...</a><p>and for those crazy people who ever far to trusting:<p><pre><code> curl https://raw.github.com/stefanpenner/obfcuscatedLife.rb/master/game_of_life.rb | ruby</code></pre>
On a cool side note, I don't know if this is old, but if you Google "Conway's Game of Life", an actual game of life is run on the page: <a href="https://www.google.com/#q=conway's+game+of+life" rel="nofollow">https://www.google.com/#q=conway's+game+of+life</a>
In APL, it is one line of code <a href="http://catpad.net/michael/apl/" rel="nofollow">http://catpad.net/michael/apl/</a>. Whether it is obfuscated or not is a matter of interpretation.