login
A395076
Lexicographically earliest nonnegative sequence, where all subsequences longer than 1 term are unique and |a(n)-a(n+1)| is minimal.
0
0, 0, 1, 1, 0, 2, 2, 1, 2, 3, 3, 2, 0, 3, 4, 4, 3, 1, 3, 5, 5, 4, 5, 6, 6, 5, 3, 0, 4, 2, 4, 6, 7, 7, 6, 4, 1, 4, 7, 8, 8, 7, 5, 7, 9, 9, 8, 9, 10, 10, 9, 7, 4, 0, 5, 2, 5, 8, 6, 8, 10, 11, 11, 10, 8, 5, 1, 5, 9, 11, 12, 12, 11, 9, 6, 3, 6, 9, 12, 13, 13, 12
OFFSET
0,6
COMMENTS
After a 0 there is the number of 0 so far minus 1. - David A. Corneth, May 15 2026
EXAMPLE
a(0) = 0, because it is the earliest nonnegative term.
a(1) = 0, because difference |a(n)-a(n+1)| is minimal.
a(2) = 1, because for 0,0,0 the subsequence "0,0" already appeared.
a(3) = 1, because difference |a(n)-a(n+1)| is minimal.
a(4) = 0, because 1,1 already appeared and |a(n)-a(n+1)| is minimal and lexicographically earliest value.
PROG
(Python)
def generate_sequence(n):
seq = [0]
seen_pairs = set()
for _ in range(n):
current = seq[-1]
d = 0
while True:
if current - d >= 0 and (current, current - d) not in seen_pairs:
next_term = current - d
break
if current + d >= 0 and (current, current + d) not in seen_pairs:
next_term = current + d
break
d += 1
seen_pairs.add((current, next_term))
seq.append(next_term)
return seq
print(generate_sequence(90))
CROSSREFS
Sequence in context: A355080 A165915 A269783 * A043276 A319416 A284559
KEYWORD
nonn
AUTHOR
Marc Morgenegg, May 11 2026
STATUS
approved