{ h = [0]; w = 1; for (k=0, 5, \\ hoizontal duplication h = concat( apply(z -> imag(z)+I*real(z), h), apply(z -> w+z, h) ); \\ vertical duplication h = concat( h, apply(z -> real(z)+I*(2*w-1-imag(z)), Vecrev(h)) ); w*=2; ); m = matrix(w,w); for (n=1, #h, m[1+real(h[n]), 1+imag(h[n])]=n-1); for (n=1, #h, print (n-1" "m[1+imag(h[n]), 1+real(h[n])])); } quit