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.

A366624 Lexicographically earliest sequence of positive integers such that each subsequence enclosed by two equal terms, not including the endpoints, is distinct.

Original entry on oeis.org

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

Views

Author

Samuel Harkness, Oct 14 2023

Keywords

Comments

Every positive integer occurs infinitely many times in the sequence.
The subsequence between any two equal terms is unique. For example, consecutive values "A B A" prevents "C B C" because the subsequence "B" would be repeated between equal terms.
Two consecutive values create the empty subsequence, for this reason after {a(1), a(2)} = {1, 1}, no consecutive values will ever occur again.
A new value is always followed by 1.

Examples

			For a(9), we first try 1. If a(9) were 1, {a(8)} = {2} would be bounded by a(7) = a(9) = 1, but {2} is already bounded by a(2) = a(4) = 1.
Next, try 2. Note this would create consecutive values at {a(8), a(9)}, enclosing the empty subsequence, but this already occurred at {a(1), a(2)}.
Next, try 3. If a(9) were 3, {a(7), a(8)} = {1, 2} would be bounded by a(6) = a(9) = 3, but {1, 2} is already bounded by a(1) = a(4) = 1.
Next, try 4. 4 has yet to appear, so a(9) = 4.
		

Crossrefs

Cf. A366625 (with distinct multisets), A366631 (with distinct sets), A366493 (including endpoints), A330896, A366691.

Programs

  • C
    /* See links */
  • 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+1:])
                        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(), 87))) # Michael S. Branicky, Jan 15 2024