Langtons Ant by kotauchi

\xef\xbb\xbff={};p=0j;d=-1;r=[];i=[]\x0d
for c in range(input()):r+=[p.real];i+=[p.imag];d*=(2*f.setdefault(p,0)+1)*1j;f[p]=~f[p];p+=d\x0d
r.sort();i.sort()\x0d
for i in range(i[0],i[-1]+1):print"".join((chr(32-3*f.get(r+1j*i,0))for r in range(r[0],r[-1]+1)))

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

download

return to the top page