s = 0 unseen = 0 seen(v) = bittest(s, v) see(v) = s = bitor(s, 2^v); while (seen(unseen), unseen++) carry = [[], []] accept(n, v) = { if (seen(v), return (0); ); my (b = if (v, binary(v), [0])); if (#carry[1] + #b == #carry[2], return (0); ); my (up = concat(carry[1], b), down = carry[2], mi = min(#up, #down), mx = max(#up, #down), mix = up[1..mi] + down[1..mi]); if (#mix && Set(mix) != [1], return (0); ); if (#up > mi && up[mi+1], return (0); ); if (#down > mi && down[mi+1], return (0); ); carry = [ down[mi+1..#down], up[mi+1..#up] ]; see(v); print (n " " v); return (1); } { for (n = 0, 10 000, if (#carry[2], \\ build next value from digits in the other bisection v = 0; for (k = 1, #carry[2], v = 2*v + 1-carry[2][k]; if (accept(n, v), next (2); ); ); v0 = v; v1 = v; while (1, v0 = 2*v0; v1 = 2*v1+1; for (v = v0, v1, if (accept(n, v), next(3); ); ); ), \\ brute force for (v = unseen, oo, if (!seen(v) && accept(n, v), break; ); ); ); ); } quit