OFFSET
1,2
COMMENTS
Erase a comma if the last digit of previous term and first digit of the following term have the same parity.
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..10000
Michael De Vlieger, Log log scatterplot of a(n), n = 1..10^5, showing even terms in red and odd in dark blue.
EXAMPLE
1112 is in the sequence. We can check by looking at where 11 and 12 appear in the list of natural numbers {..., 10, 11, 12, 13, ...}. The digits that flank the comma in the pair (10,11) are {0,1}, which have opposite parity, so we keep the comma between 10 and 11. This gives {..., <--10, 11-->, ...} [the <-- --> arrows indicate the possibility of more digits to the left and right. Note that 910 is also a member!]. Checking the flanking digits in the pair (11,12), we see that {1,1} have the same parity, so the comma is deleted there to give {..., <--10, 1112-->, ...}. We must keep checking additional pairs to the right until we find a comma. (12,13) has flanking digits {2,1} with opposite parity, so no comma is deleted. Now we see that 1112 is a member, since {..., <--10, 1112, 13-->, ...}.
MATHEMATICA
nn = 120; j = {0}; Rest@ Reap[Do[Set[k, IntegerDigits[n]]; If[Mod[Last[j], 2] == Mod[First[k], 2], j = Join[j, k], Sow[FromDigits[j]]; j = k], {n, nn}] ][[-1, 1]] (* Michael De Vlieger, Nov 24 2023 *)
PROG
(Python)
from itertools import count, islice
def agen():
cat = ""
for i in count(1):
s = str(i)
if cat != "" and int(cat[-1])%2 != int(s[0])%2:
yield int(cat)
cat = ""
cat += s
print(list(islice(agen(), 55))) # Michael S. Branicky, Nov 18 2023
CROSSREFS
KEYWORD
AUTHOR
Wesley Ivan Hurt, Nov 12 2023
STATUS
approved