login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Lexicographically earliest sequence of positive integers such that each multiset enclosed by two equal terms, excluding the endpoints, is distinct.
6

%I #49 Jan 15 2024 18:45:04

%S 1,1,2,1,2,3,1,2,4,1,2,3,2,1,5,1,2,3,4,1,2,3,4,2,1,5,3,1,2,4,2,1,5,3,

%T 4,1,2,6,1,2,3,4,5,1,2,4,3,7,1,2,3,4,5,3,1,2,6,2,1,3,4,5,7,1,2,3,4,5,

%U 6,1,2,3,4,7,2,1,3,4,5,6,1,2,4,3,5,8,1

%N Lexicographically earliest sequence of positive integers such that each multiset enclosed by two equal terms, excluding the endpoints, is distinct.

%C Every positive integer occurs infinitely many times in the sequence.

%C The multiset between any two equal terms is unique. For example: once consecutive values "A B C A" occur, both "D B C D" and "D C B D" can never occur, because the multiset "B C" would be repeated between equal terms.

%C Two consecutive values enclose the empty multiset. For this reason, after [a(1), a(2)] = [1, 1], no consecutive equal values will occur again.

%C A new value is always followed by 1.

%C The sequence first differs from A366624 at a(15).

%H Michael S. Branicky, <a href="/A366625/b366625.txt">Table of n, a(n) for n = 1..7522</a>

%H Samuel Harkness, <a href="/A366625/a366625.m.txt">MATLAB program</a>.

%H Neal Gersh Tolunsky, <a href="/A366625/a366625.png">Ordinal Transform of 5000 terms</a>.

%e a(15) = 5: a(15) cannot be 1 since this would form the empty multiset with a(14) = 1. a(15) cannot be 2 because this would form the multiset [2 1 2] = {1}, which already occurred at [2 1 2] = {1}. a(15) cannot be 3 because this would form the multiset [3 2 1 3] = {1, 2}, which already occurred at [1 1 2 1] = {1, 2}. a(15) cannot be 4 because this would form the multiset [4 1 2 3 2 1 4] = {1, 1, 2, 2, 3}, which already occurred at [1 1 2 1 2 3 1] = {1, 1, 2, 2, 3}. a(15) = 5 because 5 is a first occurrence and thus creates no new multisets.

%e For this sequence, the multisets between k and all other occurrences of k must be checked. The first instance such that this is the sole reason for restricting a possible value is when considering 2 for a(27).

%e a(27) != 2 since 2 there would cause two enclosed multisets with the same 5 terms (in different order, which doesn't matter for a multiset),

%e n = 15 19 22 26 27

%e a(n) = 1 5 1 2 3 4 1 2 3 4 2 1 5 [2]

%e |-------| |-------|

%e There are also instances where overlapping conflicting regions are the sole reason for restricting a possible value.

%e a(74) != 5 since 5 there would cause two enclosed multisets with the same 20 terms,

%e n = 38 54

%e a(n) = 2 6 1 2 3 4 5 1 2 4 3 7 1 2 3 4 5 3 1

%e |----------------------------------

%e |--

%e n = 57 73

%e a(n) = 2 6 2 1 3 4 5 7 1 2 3 4 5 6 1 2 3 4[5]

%e --|

%e ----------------------------------|

%o (MATLAB) See Links section.

%o (Python)

%o from itertools import islice

%o def agen(): # generator of terms

%o m, a = set(), []

%o while True:

%o an, allnew = 0, False

%o while not allnew:

%o allnew, an, mn = True, an+1, set()

%o for i in range(len(a)):

%o if an == a[i]:

%o t = tuple(sorted(a[i+1:]))

%o if t in m or t in mn: allnew = False; break

%o mn.add(t)

%o yield an; a.append(an); m |= mn

%o print(list(islice(agen(), 87))) # _Michael S. Branicky_, Oct 25 2023

%Y Cf. A366624, A366631, A366493, A330896.

%K nonn

%O 1,3

%A _Samuel Harkness_, Oct 14 2023