OFFSET
1,2
LINKS
Éric Angelini, More Levenshtein distances, Personal blog, December 2023.
EXAMPLE
a(1) = 1 and a(2) = 2 are separated by an Ld of 1, and 1 is the last digit of a(1)
a(2) = 2 and a(3) = 11 are separated by an Ld of 2, and 2 is the last digit of a(2)
a(3) = 11 and a(4) = 12 are separated by an Ld of 1, and 1 is the last digit of a(3)
a(4) = 12 and a(5) = 3 are separated by an Ld of 2, and 2 is the last digit of a(4)
a(5) = 3 and a(6) = 101 are separated by an Ld of 3, and 3 is the last digit of a(5), etc.
MATHEMATICA
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]
PROG
(Python)
from itertools import islice
from Levenshtein import distance as Ld
def agen(): # generator of terms
an, aset, mink = 1, {1}, 2
while True:
yield an
s, k = str(an), mink
target = int(s[-1])
while k%10 == 0 or k in aset or Ld(s, str(k)) != target: k += 1
an = k
aset.add(k)
while mink in aset or mink%10 == 0: mink += 1
print(list(islice(agen(), 57))) # Michael S. Branicky, Dec 01 2023
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Eric Angelini and Giorgos Kalogeropoulos, Dec 01 2023
STATUS
approved