A-Mazed

This nifty piece of obfuscated C was mentioned in a recent Slashdot thread. It’ arranged to spell the word "maze"; it is itself a valid maze, with the "–" decrement operators acting as the entrance and exit; and when compiled with gcc’s -fwritable-strings option it will generate a maze of any length. People with this much time on their hands deserve our respect.

char*M,A,Z,E=40,J[40],T[40];main(C){for(*J=A=scanf(M="%d",&C);
--            E;             J[              E]             =T
[E   ]=  E)   printf("._");  for(;(A-=Z=!Z)  ||  (printf("\n|"
)    ,   A    =              39              ,C             --
)    ;   Z    ||    printf   (M   ))M[Z]=Z[A-(E   =A[J-Z])&&!C
&    A   ==             T[                                  A]
|6<<27<rand()||!C&!Z?J[T[E]=T[A]]=E,J[T[A]=A-Z]=A,"_.":" |"];}
CategoriesUncategorized