unseen = 0 tr(v)=if (v>=0, 1+2*v, -2*v) s = 0 seen(v) = my (w=tr(v)); bittest(s,w) see(v) = my (w=tr(v)); s=bitor(s,2^w); while (seen(unseen) && seen(-unseen), unseen++) n = -1 emit(v) = { see(v); print (n++ " " v); last v = v; } { emit(0); for (n = 1, 5 000, \\ up for (x = 1, oo, w = last v + x^2; if (w > 0 && !seen(w), emit(w); break; ); ); \\ down for (x = 1, oo, w = last v - x^2; if (w < 0 && !seen(w), emit(w); break; ); ); ); } quit