tr(v)=if (v>=0, 1+2*v, -2*v) big = 100000 s = [] S = [] seen(z)=my (x=tr(real(z)),y=tr(imag(z)));if (max(x,y)>big, setsearch(S,z), x>#s, 0, bittest(s[x],y)) see(z)=my (x=tr(real(z)),y=tr(imag(z)));if (max(x,y)>big, S=setunion(S,Set(z)); return, x>#s, s=concat(s,vector(x-#s))); s[x]=bitor(s[x],2^y) \\ knight moves moves = concat(apply(k -> [2+I,2-I]*I^k, [0..3])) compute(n) = { if (n==1, z=0, n==2, z=2+I, my (best=oo); for (k=1, #moves, my (zz=z+moves[k]); if (!seen(zz), if (best==oo || norm(best)>norm(zz) || (norm(best)==norm(zz) && imag(zz/z)>0), best = zz; ) ); ); if (best==oo, quit, z = best ); ); see(z); return (z); } for (n=1, oo, z=compute(n); print (n " " imag(z))) quit