login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A367810 Lexicographically earliest sequence of distinct positive terms not ending in 0 such that the Levenshtein distance (Ld) between a(n) and a(n+1) is equal to the last digit of a(n). 1

%I #16 Dec 20 2023 08:04:36

%S 1,2,11,12,3,101,102,13,201,21,22,4,1001,1002,103,5,10001,10002,1003,

%T 14,2001,2002,203,6,100001,100002,10003,104,2211,211,111,112,15,20001,

%U 20002,202,23,105,22211,2221,221,121,122,16,200001,200002,20003,204,1111,1011,1012,106,222211,22221,2222,212,17

%N Lexicographically earliest sequence of distinct positive terms not ending in 0 such that the Levenshtein distance (Ld) between a(n) and a(n+1) is equal to the last digit of a(n).

%H Éric Angelini, <a href="https://cinquantesignes.blogspot.com/2023/12/more-levenshtein-distances.html">More Levenshtein distances</a>, Personal blog, December 2023.

%e a(1) = 1 and a(2) = 2 are separated by an Ld of 1, and 1 is the last digit of a(1)

%e a(2) = 2 and a(3) = 11 are separated by an Ld of 2, and 2 is the last digit of a(2)

%e a(3) = 11 and a(4) = 12 are separated by an Ld of 1, and 1 is the last digit of a(3)

%e a(4) = 12 and a(5) = 3 are separated by an Ld of 2, and 2 is the last digit of a(4)

%e a(5) = 3 and a(6) = 101 are separated by an Ld of 3, and 3 is the last digit of a(5), etc.

%t a[1]=1;a[n_]:=a[n]=(k=1; While[MemberQ[Array[a,n-1],k] ||Mod[k,10]==0|| EditDistance[ToString@a[n-1],ToString@k]!= Mod[a[n-1],10],k++];k);Array[a,40]

%o (Python)

%o from itertools import islice

%o from Levenshtein import distance as Ld

%o def agen(): # generator of terms

%o an, aset, mink = 1, {1}, 2

%o while True:

%o yield an

%o s, k = str(an), mink

%o target = int(s[-1])

%o while k%10 == 0 or k in aset or Ld(s, str(k)) != target: k += 1

%o an = k

%o aset.add(k)

%o while mink in aset or mink%10 == 0: mink += 1

%o print(list(islice(agen(), 57))) # _Michael S. Branicky_, Dec 01 2023

%Y Cf. A367638.

%K base,nonn

%O 1,2

%A _Eric Angelini_ and _Giorgos Kalogeropoulos_, Dec 01 2023

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 8 01:04 EDT 2024. Contains 375018 sequences. (Running on oeis4.)