Files
Cody Boone Ferguson b3b4027b73 Add alt code to 1985/shapiro
This alt code allows one to resize the maze. Obviously if one uses -D
with a value that's not a number it will fail to compile. If it's <= 0
|| >= 5000 it will set to the default of 39.

The try.alt.sh script plays with this, first selecting a random number
(in range $RANDOM % 38) to compile with and then run. After that it runs
in an infinite loop, exiting only if input includes non-digit
characters. A value >= 5000 sets it to the default of 39 (in the code).
2023-11-15 14:57:06 -08:00

15 lines
583 B
C

#define P(X)j=write(1,X,1)
#ifndef C
#define C 39
#elif C <= 0 || C >= 5000
#undef C
#define C 39
#endif
int M[5000]={2},*u=M,N[5000],R=22,a[4],l[]={0,-1,C-1,-1},m[]={1,-C,-1,C},*b=N,
*d=N,c,e,f,g,i,j,k,s;main(){for(M[i=C*R-1]=24;f|d>=b;){c=M[g=i];i=e;for(s=f=0;
s<4;s++)if((k=m[s]+g)>=0&&k<C*R&&l[s]!=k%C&&(!M[k]||!j&&c>=16!=M[k]>=16))a[f++
]=s;if(f){f=M[e=m[s=a[rand()/(1+2147483647/f)]]+g];j=j<f?f:j;f+=c&-16*!j;M[g]=
c|1<<s;M[*d++=e]=f|1<<(s+2)%4;}else e=d>b++?b[-1]:e;}P(" ");for(s=C;--s;P("_")
)P(" ");for(;P("\n"),R--;P("|"))for(e=C;e--;P("_ "+(*u++/8)%2))P("| "+(*u/4)%2
);}