r=-1,0,1,0,0,d=v=x=y=0 a=(r*99).map{[0]*99} s="" 1001.times{ v=a[y+d%3*99][x]^=1 s<<49-v x+=r[v<1?d:4-d] y+=r[v>0?d:-d] d=v>0?-~d%6:~-d%6} $><