Langtons Ant by nn

a[9999];d;main(u,l,n,i,j,p,x){for(a[l=i=p=1525]=scanf("%d",&n);~n--;i=p<i?p:i)a[p]^=1,p+="\x003d1"[d=d+3-a[p]*2&3]-50,x=p%50,l=x<l?x:l,u=x>u?x:u;for(i/=50;i<99;i++)for(j=l;putchar(j>u?10:3*a[50*i+j++]+32)-10;);}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page