Langtons Ant by twobit

i=io.read()p=({185,31,1327})[i%7%5]s=i%567%91%53
r=0
for _=1,i do
a=_G[p]or-1
_G[p]=-a
r=r-a
p=p+({-1,-s,1,s})[r%4+1]end
for i=0,i,s do
a=""for j=i,i+s-1 do
a=a..a.char(35*(_G[j]or-1)%67)end
print(a)end

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

download

return to the top page