A367813 Lexicographically earliest sequence of distinct nonnegative terms such that the Levenshtein distance (Ld) between a(n) and a(n+1) is equal to 3.
0, 111, 2, 100, 3, 101, 4, 102, 5, 103, 6, 104, 7, 105, 8, 106, 9, 107, 21, 108, 22, 109, 23, 110, 24, 112, 20, 113, 25, 114, 26, 115, 27, 116, 28, 117, 29, 118, 30, 119, 32, 140, 31, 120, 33, 121, 34, 122, 35, 123, 36, 124, 37, 125, 38, 126, 39, 127, 40, 128, 41, 129, 43, 150, 42, 130, 44, 131, 45, 132, 46, 133
Offset: 1
Examples
a(1) = 0 and a(2) = 111 are separated by a Ld of 3 a(2) = 111 and a(3) = 2 are separated by a Ld of 3 a(3) = 2 and a(4) = 100 are separated by a Ld of 3 a(4) = 100 and a(5) = 3 are separated by a Ld of 3, etc.
Links
- Éric Angelini, More Levenshtein distances, Personal blog, December 2023.
Programs
-
Mathematica
a[1]=0;a[n_]:=a[n]=(k=1;While[MemberQ[Array[a,n-1],k]||EditDistance[ToString@a[n-1],ToString@k]!=3,k++];k);Array[a,72]
-
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)) != 3: k += 1 an = k aset.add(k) while mink in aset: mink += 1 print(list(islice(agen(), 72))) # Michael S. Branicky, Dec 01 2023