login
Underline the k-th digit of a(n), k being the leftmost digit of a(n). This is the lexicographically earliest sequence of distinct terms > 0 such that the succession of underlined digits is the succession of the sequence's digits themselves.
2

%I #30 Oct 23 2023 18:53:05

%S 1,10,20,22,200,220,221,222,201,202,223,224,203,225,226,11,227,228,

%T 229,302,204,12,312,205,322,332,342,23,352,362,24,372,206,230,382,392,

%U 25,2200,2201,26,13,14,2202,2203,27,2204,2205,28,2206,2207,29,231,207,2208,2209,208,240,15,2210,232,16,2211

%N Underline the k-th digit of a(n), k being the leftmost digit of a(n). This is the lexicographically earliest sequence of distinct terms > 0 such that the succession of underlined digits is the succession of the sequence's digits themselves.

%H John Tyler Rascoe, <a href="/A364325/b364325.txt">Table of n, a(n) for n = 1..10000</a>

%e The leftmost digit of a(1) = 1 is 1: this digit underlines the 1st digit of a(1) which is (1);

%e The leftmost digit of a(2) = 10 is 1: this digit underlines the 1st digit of a(2) which is (1);

%e The leftmost digit of a(3) = 20 is 2: this digit underlines the 2nd digit of a(3) which is (0);

%e The leftmost digit of a(4) = 22 is 2: this digit underlines the 2nd digit of a(4) which is (2);

%e The leftmost digit of a(5) = 200 is 2: this digit underlines the 2nd digit of a(5) which is (0);

%e The leftmost digit of a(6) = 220 is 2: this digit underlines the 2nd digit of a(6) which is (2); etc.

%e We see that the parenthesized digits at the end of each line reproduce the succession of the original digits.

%t a[1]=1;a[n_]:=a[n]=(k=1;While[If[(f=First@IntegerDigits[k])>IntegerLength@k,True, If[IntegerDigits[k][[f]]!=Flatten[IntegerDigits/@Join[Array[a,n-1],{k}]][[n]]||MemberQ[Array[a,n-1],k],True]],k++];k);Array[a,70] (* _Giorgos Kalogeropoulos_, Jul 19 2023 *)

%o (Python)

%o from itertools import count, filterfalse

%o def check(x):

%o y = str(x)

%o if int(y[0])> len(y): return(True)

%o def A364325_list(max_n):

%o A,S,Z,zx = [],set(),'',0

%o for n in range(1,max_n+1):

%o for i in filterfalse(S.__contains__, count(1)):

%o if check(i): S.add(i)

%o else:

%o x = str(i)

%o u = x[int(x[0])-1]

%o if len(Z) == zx and u == x[0]: break

%o elif u == Z[zx]: break

%o A.append(i); S.add(i); Z += x; zx += 1

%o return(A) # _John Tyler Rascoe_, Oct 23 2023

%Y Cf. A364326.

%K base,nonn

%O 1,2

%A _Eric Angelini_, Jul 18 2023