%I #11 Dec 21 2023 15:17:10
%S 0,111,2,100,3,101,4,102,5,103,6,104,7,105,8,106,9,107,21,108,22,109,
%T 23,110,24,112,20,113,25,114,26,115,27,116,28,117,29,118,30,119,32,
%U 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
%N Lexicographically earliest sequence of distinct nonnegative terms such that the Levenshtein distance (Ld) between a(n) and a(n+1) is equal to 3.
%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) = 0 and a(2) = 111 are separated by a Ld of 3
%e a(2) = 111 and a(3) = 2 are separated by a Ld of 3
%e a(3) = 2 and a(4) = 100 are separated by a Ld of 3
%e a(4) = 100 and a(5) = 3 are separated by a Ld of 3, etc.
%t 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]
%o (Python)
%o from itertools import islice
%o from Levenshtein import distance as Ld
%o def agen(): # generator of terms
%o an, aset, mink = 0, {0}, 1
%o while True:
%o yield an
%o s, k = str(an), mink
%o while k in aset or Ld(s, str(k)) != 3: k += 1
%o an = k
%o aset.add(k)
%o while mink in aset: mink += 1
%o print(list(islice(agen(), 72))) # _Michael S. Branicky_, Dec 01 2023
%Y Cf. A118763, A367812, A367814, A367815.
%K base,nonn
%O 1,2
%A _Eric Angelini_ and _Giorgos Kalogeropoulos_, Dec 01 2023
|