logoalt Hacker News

tromptoday at 6:49 AM1 replyview on HN

When code is a maze describes my 1988 IOCCC entry [1]

    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,"_.":" |"];}
[1] https://tromp.github.io/pearls.html#maze

Replies

ghgrtoday at 7:41 AM

Very cool, thanks for sharing!

If, like me, you're trying to compile it, don't forget to set the

    -std=gnu89
flag in gcc, so:

    gcc -std=gnu89 -w -o maze maze.c
Then run it as:

    echo 10 | ./maze
show 1 reply