Langtons Ant by koi

m[9801],p=4900,d,x,y,X,Y;main(s,w){scanf("%d",&s);for(x=y=X=Y=49;s--;)d=(d+1-m[p])&3,m[p]^=2,p+=d&1?99*(d-2):d-1,w=p/99,y=w<y?w:y,Y=w>Y?w:Y,w=p%99,x=w<x?w:x,X=w>X?w:X;for(;y<=Y;++y)for(w=x;w<X+2;++w)putchar(w>X?10:m[y*99+w]?35:32);}

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

download

return top