Langtons Ant by m.ukai

let p,a,n=print_char,Array.make_matrix 99 99 0,read_int()let q=n/999mod 9
let rec f x y?(c=a.(x).(y))d?(k=1-c)e?(g=(d+1)mod 2*e*(k-c))?(h=(e+1)mod 2*d*(c-k))i=a.(x).(y)<-k;i>1&f(x+g)(y+h)g h(i-1);;f 29 22 0(-1)n;for i=[|26;18;0|].(q)to 98do
for j=[|18;13;0|].(q)to[|26;28;44|].(q)do
p" #".[a.(i).(j)]done;p '
'done

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

download

return to the top page