Langtons Ant by uru

var a:array[-99..99,-99..99]of comp;e,g,h,n,p,q,x,y,s,t,u:comp;begin
read(n);q:=-1;repeat
t:=a[x,y];u:=(-1)pow t;s:=q*u;q:=-p*u;p:=s;a[x,y]:=1-t;x:=x+p;y:=y+q;e:=min(e,x);g:=min(g,y);h:=max(h,y);dec(n)until n=0;for x:=e to 99do for y:=g to h do write(chr(32+3*a[x,y]),^j:ord(y=h))end.

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

download

return to the top page