
EXAMPLE

[0] > a(0) = 0.
[0,1] > a(1) = 1  0 = 1.
[0,1,2] > a(2) = 10  2 = 8.
[0,1,2,3] > a(3) = 20  13 = 7.
[0,1,2,3,4] > a(4) = 102  43 = 59.
[0,1,2,3,4,5] > a(5) = 301  254 = 47.
[0,1,2,3,4,5,6] > a(6) = 1023  654 = 369.
[0,1,2,3,4,5,6,7] > a(7) = 4012  3765 = 247.
[0,1,2,3,4,5,6,7,8] > a(8) = 10234  8765 = 1469.
[0,1,2,3,4,5,6,7,8,9] > a(9) = 50123  49876 = 247.
[0,1,2,3,4,5,6,7,8,9,0] > a(10) = 100234  98765 = 1469.
[0,1,2,3,4,5,6,7,8,9,0,1] > a(11) = 150023  149876 = 147.
[0,1,2,3,4,5,6,7,8,9,0,1,2] > a(12) = 1001223  987654 = 13569.
a(20) = 12446689 = 10001223344  9988776655.  David A. Corneth, Jul 26 2018


MAPLE

with(numtheory): with(combinat): P:=proc(q)
local a, b, c, d, f, i, j, m, n, p, k, s, x, y, w, z;
a:=[0, 1]; print(0); print(1); for n from 2 to q do b:=10^20;
a:=[op(a), n mod 10]; c:=ceil(nops(a)/2); d:=choose(a, c);
for k from 1 to nops(d) do x:=permute(d[k]);
for j from 1 to nops(x) do f:=a; for m from 1 to nops(x[j]) do
for p from 1 to nops(f) do if f[p]=x[j][m] then
f:=subsop(p=NULL, f); break; fi; od; od; y:=0;
for i from 1 to c do y:=10*y+x[j][i]; od; z:=permute(f);
for i from 1 to nops(z) do w:=0; for s from 1 to nops(z[i]) do
w:=10*w+z[i][s]; od;
if yw>0 and ilog10(y)+1=c and ilog10(w)+1=nops(a)c and yw<b then b:=yw; fi; od; od; od; print(b); od; end: P(10);
