login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Lexicographically earliest sequence such that each set of terms enclosed by two equal values, including the endpoints, contains a distinct number of elements.
1

%I #23 Nov 28 2024 11:26:22

%S 1,1,2,3,2,4,3,5,6,4,7,3,8,9,5,10,6,11,12,7,13,3,14,15,16,8,17,9,18,5,

%T 19,20,10,21,6,22,23,11,24,12,25,26,13,27,3,28,29,30,31,14,32,15,33,

%U 16,34,8,35,36,17,37,9,38,39,18,40,5,41,42,43,19,44,20,45

%N Lexicographically earliest sequence such that each set of terms enclosed by two equal values, including the endpoints, contains a distinct number of elements.

%C The word 'set' means that every element is unique. For example, the set {1,1,2} contains 2 elements (not 3).

%C Note that we are considering sets between every pair of equal values, not just those that appear consecutively.

%C Two consecutive values enclose 1 term, and thus after [a(1), a(2)] = [1, 1], no consecutive equal values occur again.

%H Neal Gersh Tolunsky, <a href="/A378381/b378381.txt">Table of n, a(n) for n = 1..10000</a>

%e a(4) cannot be 1 since this would create a second pair enclosing two values, [1,2,1] being an equivalent set to [1,2,1,1]. We cannot have a(4)=2 because [1,2,1] would enclose the same number of elements as [2,1,2]. So a(4)=3, which has not occurred before.

%o (Python)

%o from itertools import islice

%o def agen(): # generator of terms

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

%o while True:

%o an, allnew = 0, False

%o while not allnew:

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

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

%o if an == a[i]:

%o nd = len(set(a[i:]))

%o if nd in e or nd in ndset: allnew = False; break

%o ndset.add(nd)

%o yield an; a.append(an); e |= ndset

%o print(list(islice(agen(), 73))) # _Michael S. Branicky_, Nov 26 2024

%Y Cf. A366691.

%K nonn

%O 1,3

%A _Neal Gersh Tolunsky_, Nov 26 2024