A366624 Lexicographically earliest sequence of positive integers such that each subsequence enclosed by two equal terms, not including the endpoints, is distinct.
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
Keywords
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.
Links
- Michael S. Branicky, Table of n, a(n) for n = 1..6804 (terms 1..1000 from Neal Gersh Tolunsky)
- Samuel Harkness, MATLAB program.
- Kevin Ryde, C Code.
Crossrefs
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
Comments