Langtons Ant by nn

a=[]
a[l=p=1525]=1
for(n=readline(i=u=d=0);~n--;x=p%50,l=x<l?x:l,u=x>u?x:u)a[p]^=1,p+=[-50,1,50,-1][d=d+(a[p]?1:3)&3]
for(;i++<99;/#/(s)&&print(s))for(j=l,s='';j<=u;j++)s+=a[50*i+j]?'#':' '

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

download

return to the top page