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.

A366493 Lexicographically earliest sequence such that each subsequence enclosed by two equal terms is distinct.

Original entry on oeis.org

1, 1, 2, 1, 2, 2, 1, 3, 1, 2, 3, 1, 2, 4, 1, 2, 3, 2, 1, 3, 2, 1, 4, 1, 2, 3, 3, 1, 2, 4, 2, 1, 3, 4, 1, 2, 3, 4, 1, 2, 4, 3, 1, 2, 4, 3, 2, 1, 4, 2, 1, 3, 5, 1, 2, 3, 4, 2, 1, 3, 5, 2, 1, 3, 4, 2, 1, 4, 3, 1, 2, 5, 1, 2, 3, 4, 3, 1, 2, 5, 2, 1, 3, 4, 4, 1, 2, 3, 5, 1, 2, 4, 3, 4, 1, 2, 5, 3, 1, 2, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 5
Offset: 1

Views

Author

Neal Gersh Tolunsky, Oct 10 2023

Keywords

Comments

A new value is always followed by 1.

Examples

			a(2)=1 because the subsequence (1,1) has not occurred before.
a(8)=3 because every smaller number would form a subsequence that has occurred already. a(8) cannot be 1 because this would make the subsequence (1,1), which was seen before at i=1,2. a(8) cannot be 2 because then we would have the subsequence (2,1,2) for a second time (first at i=3-5): 1,1,2,1,2,2,1,2
		

Crossrefs

Cf. A330896.

Programs

  • MATLAB
    See Links section.
    
  • Python
    from itertools import islice
    def agen(): # generator of terms
        m, a = set(), []
        while True:
            an, allnew = 0, False
            while not allnew:
                allnew, an, mn = True, an+1, set()
                for i in range(len(a)):
                    if an == a[i]:
                        t = tuple(a[i:]+[an])
                        if t in m or t in mn: allnew = False; break
                        mn.add(t)
            yield an; a.append(an); m |= mn
    print(list(islice(agen(), 111))) # Michael S. Branicky, Dec 06 2024