rem = List([1]) \\ free values w = 1 \\ chunk length unseen = rem[#rem]+1 \\ values >= unseen are all free nth(n) = { if (n > #rem, rem = List(concat(Vec(rem), [unseen..(unseen+=2*w=max(w,n))-1])); ); my (v=rem[n]); listpop(rem, n); return (v); } { a = vector(10 000); u = 1; h = 1; for (n=1, oo, v = nth(h); if (v<=#a, a[v] = n; while (a[u], print (u " " a[u]); if (u++==#a, break (2); ); ); ); h = hammingweight(v); ); } quit