Written
on
Conway's Game of Life redefined
I have no clue where I found this clever implementation of Conway’s Game of Life but I like it a lot:
char*b=
" "
" "
" ## "
" ## "
" # "
" "
" "
" "
,*dna[]={
"};main(){int i,j,k,n;char*p;puts(xchar*b=x);for(i=0;i<64;i++,i&7||puts(xzxx))",
"{i&7||putchar(34);for(n=-b[i],k=-8,j=0;j<9;j++,jy3||(k+=8))n+=b[(i+k&56)",
"|(i+jy3-1&7)];putchar(x #x[n==262&&b[i]==35||n==265]);}puts(x,*dna[]={x);for",
"(i=0;i<5;i++)printf(xzxyszx,znx,dna[i]);for(i=0;i<5;i++,putchar(10))for(",
"p=dna[i];*p;++p)putchar(*p==120?34:*p==121?37:*p==122?92:*p);}",
};main(){int i,j,k,n;char*p;puts("char*b=");for(i=0;i<64;i++,i&7||puts("\""))
{i&7||putchar(34);for(n=-b[i],k=-8,j=0;j<9;j++,j%3||(k+=8))n+=b[(i+k&56)
|(i+j%3-1&7)];putchar(" #"[n==262&&b[i]==35||n==265]);}puts(",*dna[]={");for
(i=0;i<5;i++)printf("\"%s\",\n",dna[i]);for(i=0;i<5;i++,putchar(10))for(
p=dna[i];*p;++p)putchar(*p==120?34:*p==121?37:*p==122?92:*p);}
The result shouldn’t be that surprising, if you know anything about Quines:
$ gcc -o life life.c 2>/dev/null
$ ./life > life2.c
$ diff -U0 life.c life2.c
--- life.c 2005-06-05 00:42:34.000000000 +0200
+++ life2.c 2020-06-05 00:43.30.707297628 +0200
@@ -2,8 +2,8 @@
-" "
-" "
-" ## "
-" ## "
-" # "
-" "
-" "
-" "
+" "
+" "
+" ### "
+" # "
+" ## "
+" "
+" "
+" "