big = 1 000 000 s = 0 S = [] unseen = 0 seen(v) = if (v < big, bittest(s, v), setsearch(S, v)) see(v) = if (v < big, s = bitor(s, 2^v), S = setunion(S, [v])); while (seen(unseen), unseen++) \\ least k unseen / v AND k = 0 cc = [0] avoid(v) = { if (!seen(0), return (0); ); my (b, c, nb=1); for (e=0, oo, if (!bittest(v,e), if (nb==#cc, cc=concat(cc, vector(#cc)); ); b=2^e; for (k=1, nb, c = cc[nb+k] = cc[k]+b; if (!seen(c), return (c); ); ); nb*=2; ); ); } n = 0 a = [0] b = vector(10 000) u = 1 emit(v) = { n++; if (v && v <= #b, b[v] = n-1; while (b[u], print (u " " b[u]); if (u++ > #b, quit; ); ); ); see(v); if (n > #a, a = concat(a, vector(#a)); ); a[n] = v; } { print ("0 0"); emit(0); for (n = 1, oo, emit(v = avoid(a[n])); emit(avoid(v + a[n])); ); } quit