s = 0 unseen = 0 seen(v) = bittest(s, v) see(v) = s = bitor(s, 2^v); while (seen(unseen), unseen++) base = 2 cat(x, y) = x * base^#digits(y, base) + y ispal(x) = my (d = if (x, digits(x / base^valuation(x, base), base), [])); d==Vecrev(d) other(n) = { see(n); for (v = unseen, oo, if (!seen(v), if (ispal(cat(n, v)) || ispal(cat(v, n)), return (v); ); ); ); } for (n = 0, 2^13-1, print (n " " v = if (n==0, 0, other(v)))) quit