Langtons Ant by twobit

r=i=input()
p=[1327,31,185][i%11&3]
s=i%567%91%53
f=[32]*i
while i:i-=1;f[p]^=3;r+=f[p]|1;p+=[-1,s,1,-s][r%4]
while f:print`map(chr,f[:s])`[2::5];f=f[s:]

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

download

return to the top page