OFFSET
1,2
COMMENTS
The sequence starts with a(1) = 1 and is always extended with the smallest positive integer not yet present that does not lead to a contradiction.
No term can end with an odd number of successive 0.
This is not the sequence A329127 as they diverge at a(55).
EXAMPLE
a(1) = 1 forces the next digit to be a 1 (as digits must come in pairs); the smallest positive integer not yet present that starts with a 1 and does not lead to a contradiction is 11 (as 10, ending with an odd number of 0, is forbidden). Thus, a(2) = 11;
a(3) = 12 as a(3) must start with a 1 (to complete a pair of identical digits), and 12 is the smallest positive integer not yet present that does not lead to a contradiction;
a(4) = 2 as 2 is the smallest positive integer not yet present that starts with a 2 and does not lead to a contradiction; etc.
PROG
(Python)
mustpair = set(range(10))
def pairsup(n, offset=0):
digits = list(map(int, str(n)))[offset:]
if len(digits) == 0: return True, False
i = 0
while i < len(digits) - 1:
if digits[i] in mustpair:
if digits[i] != digits[i+1]: return False, None
else: i += 2
else: i += 1
unpaired = digits[-1] in mustpair and i != len(digits)
return not (unpaired and digits[-1] == 0), unpaired
def aupton(terms, startswith=1):
alst, unpaired = [startswith], startswith in mustpair
for n in range(2, terms+1):
m = 1
while True:
while m in alst: m += 1
if not unpaired or int(str(m)[0]) == alst[-1]%10:
passes, temp = pairsup(m, offset=int(unpaired))
if passes: alst.append(m); unpaired = temp; break
m += 1
return alst
print(aupton(66)) # Michael S. Branicky, Feb 28 2021
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Eric Angelini, Feb 28 2021
STATUS
approved
