login
Integers x such that [f(0), f(f(0)), ..., f(...f(0)...)] is a permutation of [0, 1, ..., k-1], where k is the number of digits in x and f(a) denotes the 0-based index of the first occurrence of the substring a in x.
0

%I #29 Jul 16 2019 11:47:00

%S 0,10,120,201,1230,1302,2031,2310,3012,3201,12340,12403,13042,13420,

%T 14023,14302,20341,20413,23140,23401,24103,24310,30142,30421,32041,

%U 32410,34012,34120,40123,40312,42013,42301,43021,43102

%N Integers x such that [f(0), f(f(0)), ..., f(...f(0)...)] is a permutation of [0, 1, ..., k-1], where k is the number of digits in x and f(a) denotes the 0-based index of the first occurrence of the substring a in x.

%C Numbers with 21 digits cannot fit every number from 0 to 20 as strings. Hence this sequence cannot have any numbers with 21 digits or more, making it finite.

%C 1918171615141312110 is the largest number in this sequence (see examples).

%e Consider x = 40312. f(0) = 1, f(1) = 3, f(3) = 2, f(2) = 4, f(4) = 0 and so we have visited every index of x.

%e Consider the largest number in this sequence, x = 1918171615141312110. f(0) = 18, f(18) = 2, f(2) = 15, f(15) = 8, f(8) = 3, f(3) = 13, f(13) = 12, f(12) = 14, f(14) = 10, f(10) = 17, f(17) = 4, f(4) = 11, f(11) = 16, f(16) = 6, f(6) = 7, f(7) = 5, f(5) = 9, f(9) = 1, f(1) = 0 and so we have visited every index of x.

%t {{0}}~Join~Array[Block[{k = #, r}, r = Range[0, k]; FromDigits /@ Select[DeleteCases[Permutations[r, {k + 1}], _?(First@ # == 0 &)], With[{w = #}, Union@ Rest@ Nest[Append[#, Position[w, #[[-1]]][[1, 1]] - 1] &, {0}, Length@ w] == r] &]] &, 4] // Flatten (* _Michael De Vlieger_, Apr 21 2019 *)

%K nonn,fini,base

%O 1,2

%A _Dmitry Kamenetsky_, Apr 18 2019