|
|
A331975
|
|
Lexicographically earliest sequence of distinct positive integers such that three successive digits are always distinct.
|
|
3
|
|
|
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 21, 30, 12, 31, 20, 13, 24, 15, 23, 14, 25, 16, 27, 18, 26, 17, 28, 19, 32, 40, 29, 34, 50, 35, 41, 36, 42, 37, 43, 51, 38, 45, 39, 46, 52, 47, 53, 48, 54, 60, 49, 56, 70, 57, 61, 58, 62, 59, 63, 71, 64, 72, 65, 73, 67, 80, 68, 74, 69, 75, 81, 76, 82, 78, 90, 79, 83, 91, 84
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,2
|
|
LINKS
|
|
|
EXAMPLE
|
As a(10) = 10, a(11) cannot start with a 1 or have a 0 in second position; thus a(11) = 21;
as a(11) = 21, a(12) cannot start with a 1 or a 2; thus a(12) = 30;
as a(12) = 30, a(13) = 12, smallest available integer not leading to an immediate contradiction;
as a(13) = 12, a(14) cannot start with 1 or 2; thus a(14) = 31, smallest available integer not leading to an immediate contradiction. Etc.
|
|
PROG
|
(Python)
from itertools import islice
def ok(s): return all(len(set(s[i:i+3]))==3 for i in range(len(s)-2))
def agen(): # generator of terms
aset, s, k, mink = {1}, "x1", 1, 2
while True:
yield k
k, avoid = mink, set(s)
while k in aset or not ok(s + str(k)): k += 1
aset.add(k)
s = (s + str(k))[-3:]
while mink in aset: mink += 1
|
|
CROSSREFS
|
Cf. A331215 (a variant with 4 successive distinct digits instead of 3).
|
|
KEYWORD
|
base,nonn
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|