{ \\ upper left triangle tri = vector(500, k, Set()); for (n=1, #tri, if (n%2==0, tri[n] = tri[n/2], for (w=1, oo, my (f=1/n, s=Set()); if (f==1, f=f/2); while (!setsearch(s,f), i = floor(f*2^w); if (i, tri[n] = setunion(tri[n],Set(i)); ); s = setunion(s,Set(f)); f=frac(f*2); ); if (#tri[n] >= #tri+1-n, break; ); ); ); ); \\ antidiagonals flattened i = 0; for (d=1, #tri, for (k=1, d, print (i++ " " tri[d+1-k][k]); ); ); } quit