cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-2 of 2 results.

A367810 Lexicographically earliest sequence of distinct positive terms not ending in 0 such that the Levenshtein distance (Ld) between a(n) and a(n+1) is equal to the last digit of a(n).

Original entry on oeis.org

1, 2, 11, 12, 3, 101, 102, 13, 201, 21, 22, 4, 1001, 1002, 103, 5, 10001, 10002, 1003, 14, 2001, 2002, 203, 6, 100001, 100002, 10003, 104, 2211, 211, 111, 112, 15, 20001, 20002, 202, 23, 105, 22211, 2221, 221, 121, 122, 16, 200001, 200002, 20003, 204, 1111, 1011, 1012, 106, 222211, 22221, 2222, 212, 17
Offset: 1

Views

Author

Keywords

Examples

			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.
		

Crossrefs

Cf. A367638.

Programs

  • 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]
  • 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

A367797 The successive digits of the number k are the successive "inside Levenshtein distances" of k (except for the last digit of k). See the Comment section for the definition of an "inside Levenshtein distance".

Original entry on oeis.org

10, 12, 13, 14, 15, 16, 17, 18, 19, 111, 211, 2020, 2122, 2230, 2231, 2234, 2235, 2236, 2237, 2238, 2239, 3121, 31131, 32131, 32233, 32340, 32341, 32345, 32346, 32347, 32348, 32349, 42232, 422242, 432242, 432450, 432451, 432456, 432457, 432458, 432459, 433242, 433344, 532342, 5433353, 5433455, 5433560
Offset: 1

Views

Author

Keywords

Comments

Let's consider 2023 and compute the successive traditional Levenshtein distances between 2 and 023, 20 and 23, 202 and 3 (the so-called inside Lds).
We have:
Ld 2<>023 = 2,
Ld 20<>23 = 1,
Ld 202<>3 = 3.
The successive Lds of 2023 are 2, 1 and 3.

Examples

			a(1) = 10 has an iLd of 1 (the Levenshtein distance between 1 and 0) and this iLd of 1 is the first digit of a(1);
a(47) = 5433560 is in the sequence because its successive Lds are:
  Ld 5<>433560 = 5
  Ld 54<>33560 = 4
  Ld 543<>3560 = 3
  Ld 5433<>560 = 3
  Ld 54335<>60 = 5
  Ld 543356<>0 = 6.
We see that the rightmost column above reproduces a(47), except for the last digit.
		

Crossrefs

Cf. A367638.

Programs

  • Python
    from Levenshtein import distance as Ld
    def ok(n):
        s = str(n)
        if n < 10: return False # convention, though condition is vacuously True
        return all(Ld(s[:i+1], s[i+1:]) == int(s[i]) for i in range(len(s)-1))
    print([k for k in range(10**7) if ok(k)]) # Michael S. Branicky, Dec 01 2023
Showing 1-2 of 2 results.