login
a(n) = smallest number not occurring earlier having in decimal representation to its predecessor Levenshtein distance = 1; a(0)=0.
14

%I #18 Dec 01 2023 18:36:03

%S 0,1,2,3,4,5,6,7,8,9,19,10,11,12,13,14,15,16,17,18,28,20,21,22,23,24,

%T 25,26,27,29,39,30,31,32,33,34,35,36,37,38,48,40,41,42,43,44,45,46,47,

%U 49,59,50,51,52,53,54,55,56,57,58,68,60,61,62,63,64,65,66,67,69,79,70,71

%N a(n) = smallest number not occurring earlier having in decimal representation to its predecessor Levenshtein distance = 1; a(0)=0.

%C Permutation of the natural numbers; inverse: A118764; A118765(n)=a(a(n)); a(A118767(n))=A118767(n);

%C A118768(n) = a(n+1) - a(n);

%H Robert G. Wilson v, <a href="/A118763/b118763.txt">Table of n, a(n) for n = 0..10000</a>

%H Michael Gilleland, <a href="http://people.cs.pitt.edu/~kirk/cs1501/Pruhs/Fall2006/Assignments/editdistance/Levenshtein%20Distance.htm">Levenshtein Distance</a>

%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>

%t levenshtein[s_List, t_List] := Module[{d, n = Length@ s, m = Length@ t}, Which[s === t, 0, n == 0, m, m == 0, n, s != t, d = Table[0, {m + 1}, {n + 1}]; d[[1, Range[n + 1]]] = Range[0, n]; d[[Range[m + 1], 1]] = Range[0, m]; Do[ d[[j + 1, i + 1]] = Min[d[[j, i + 1]] + 1, d[[j + 1, i]] + 1, d[[j, i]] + If[ s[[i]] === t[[j]], 0, 1]], {j, m}, {i, n}]; d[[ -1, -1]] ]]; f[lst_] := Block[{k = 1, l = IntegerDigits[ lst[[-1]]]}, While[ MemberQ[lst, k] || levenshtein[l, IntegerDigits[k]] > 1, k++]; Append[lst, k]]; Nest[f, {0}, 100] (* _Robert G. Wilson v_, Sep 22 2016 *)

%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)) != 1: k += 1

%o an = k

%o aset.add(k)

%o while mink in aset: mink += 1

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

%Y Cf. A118757.

%K nonn,base

%O 0,3

%A _Reinhard Zumkeller_, May 01 2006