login
A367814
Lexicographically earliest sequence of distinct nonnegative terms such that the Levenshtein distance (Ld) between a(n) and a(n+1) is equal to 4.
3
0, 1111, 2, 1000, 3, 1001, 4, 1002, 5, 1003, 6, 1004, 7, 1005, 8, 1006, 9, 1007, 21, 1008, 22, 1009, 23, 1010, 24, 1011, 25, 1012, 26, 1013, 27, 1014, 28, 1015, 29, 1016, 32, 1017, 33, 1018, 34, 1019, 35, 1020, 31, 1022, 36, 1021, 37, 1023, 38, 1024, 39, 1025, 41, 1026, 43, 1027, 44, 1028, 45, 1029, 46, 1030
OFFSET
1,2
LINKS
Éric Angelini, More Levenshtein distances, Personal blog, December 2023.
EXAMPLE
a(1) = 0 and a(2) = 1111 are separated by an Ld of 4
a(2) = 1111 and a(3) = 2 are separated by an Ld of 4
a(3) = 2 and a(4) = 1000 are separated by an Ld of 4
a(4) = 1000 and a(5) = 3 are separated by an Ld of 4, etc.
MATHEMATICA
a[1]=0; a[n_]:=a[n]=(k=1; While[MemberQ[Array[a, n-1], k]||EditDistance[ToString@a[n-1], ToString@k]!=4, k++]; k); Array[a, 64]
PROG
(Python)
from itertools import islice
from Levenshtein import distance as Ld
def agen(): # generator of terms
an, aset, mink = 0, {0}, 1
while True:
yield an
s, k = str(an), mink
while k in aset or Ld(s, str(k)) != 4: k += 1
an = k
aset.add(k)
while mink in aset: mink += 1
print(list(islice(agen(), 64))) # Michael S. Branicky, Dec 01 2023
CROSSREFS
KEYWORD
base,nonn
AUTHOR
STATUS
approved