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.
%I A366624 #36 Dec 19 2024 11:45:36 %S A366624 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, %T A366624 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, %U A366624 1,2,4,3,2,1,4,3,2,1,5,2,1,3,4,6,1,2,4 %N A366624 Lexicographically earliest sequence of positive integers such that each subsequence enclosed by two equal terms, not including the endpoints, is distinct. %C A366624 Every positive integer occurs infinitely many times in the sequence. %C A366624 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. %C A366624 Two consecutive values create the empty subsequence, for this reason after {a(1), a(2)} = {1, 1}, no consecutive values will ever occur again. %C A366624 A new value is always followed by 1. %H A366624 Michael S. Branicky, <a href="/A366624/b366624.txt">Table of n, a(n) for n = 1..6804</a> (terms 1..1000 from Neal Gersh Tolunsky) %H A366624 Samuel Harkness, <a href="/A366624/a366624.m.txt">MATLAB program</a>. %H A366624 Kevin Ryde, <a href="/A366624/a366624.c.txt">C Code</a>. %e A366624 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. %e A366624 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)}. %e A366624 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. %e A366624 Next, try 4. 4 has yet to appear, so a(9) = 4. %o A366624 (MATLAB) See Links section. %o A366624 (Python) %o A366624 from itertools import islice %o A366624 def agen(): # generator of terms %o A366624 m, a = set(), [] %o A366624 while True: %o A366624 an, allnew = 0, False %o A366624 while not allnew: %o A366624 allnew, an, mn = True, an+1, set() %o A366624 for i in range(len(a)): %o A366624 if an == a[i]: %o A366624 t = tuple(a[i+1:]) %o A366624 if t in m or t in mn: allnew = False; break %o A366624 mn.add(t) %o A366624 yield an; a.append(an); m |= mn %o A366624 print(list(islice(agen(), 87))) # _Michael S. Branicky_, Jan 15 2024 %o A366624 (C) /* See links */ %Y A366624 Cf. A366625 (with distinct multisets), A366631 (with distinct sets), A366493 (including endpoints), A330896, A366691. %K A366624 nonn %O A366624 1,3 %A A366624 _Samuel Harkness_, Oct 14 2023