A333325 Lexicographically earliest sequence over {0,1,2} that has the shortest square subsequence.
0, 1, 0, 2, 0, 1, 0, 0, 1, 2, 0, 1, 0, 2, 0, 1, 2, 0, 2, 1, 0, 1, 2, 0, 1, 0, 2, 0, 1, 2, 0, 2, 2, 0, 1, 0, 2, 0, 1, 2, 0, 0, 1, 0, 2, 0, 1, 0, 0, 1, 2, 0, 1, 0, 2, 0, 1, 2, 0, 2, 1, 0, 1, 2, 0, 1, 0, 2, 0, 1, 2, 0, 2, 2, 0, 1, 0, 2, 0, 1, 2
Offset: 0
Keywords
Examples
a(7) = 0, since: 0 yields a square subsequence of length 2: [0, 0], 1 of length 4: [0, 1, 0, 1], 2 of length 8: [0, 1, 0, 2, 0, 1, 0, 2].
Programs
-
Python
def a333325(n): seq = [] for k in range(n): options = [] l = len(seq) + 1 for m in range(3): # base for i in range(l // 2, -1, -1): if seq[l - 2 * i: l - i] == seq[l - i:] + [m]: break options.append(2 * i) seq.append(options.index(min(options))) return seq print(a333325(81))
Comments