big = 1 000 000 s = 0 S = Set([]) unseen = 1 seen(v) = if (v < big, bit test(s, v), set search(S, v)) see(v) = if (v < big, s = bit or(s, 2^v), S = set union(S, Set([v]))); while (seen(unseen), unseen++) other(n, p) = { see(p); my (w=#binary(p), v); \\ invert leftmost binary digit ? forstep (b=w-1, 0, -1, v = bitxor(p, 2^b); if (!seen(v), print (n " " b); return (v); ); ); \\ invert rightmost leading zero ? for (b=w, oo, v = bitxor(p, 2^b); if (!seen(v), print (n " " b); return (v); ); ); } v=0; for (n=0, 2^13-1, v=other(n, v)) quit