cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A369127 S is a "boomerang sequence". Replace each digit d of S by a base-10 palindrome not yet used that contains d: the sequence S remains identical to itself if we follow each palindrome with a comma.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 101, 111, 202, 121, 131, 141, 151, 22, 303, 212, 161, 222, 171, 181, 33, 191, 313, 44, 414, 515, 55, 616, 232, 242, 323, 404, 333, 252, 717, 262, 818, 66, 919, 272, 282, 292, 1001, 77, 1111, 1221, 88, 1331, 343, 353, 1441, 99
Offset: 1

Views

Author

Eric Angelini, Mar 02 2024

Keywords

Examples

			As a(1) to a(10) are single-digit palindromes, the replacement leaves the terms a(1) to a(10) as they were.
a(11) = 11 and we must replace the first digit d = 1 of 11 by the smallest base-10 palindrome not yet used; this is 11 (as the palindrome 1 has been used before);
a(11) = 11 and we must replace now the second digit d = 1 of 11 by the smallest base-10 palindrome not yet used; this is 101 (as 1 and 11 have been used before);
a(12) = 101 and we must replace the first digit d = 1 of 101 by the smallest base-10 palindrome not yet used; this is 111;
a(12) = 101 and we must now replace the digit d = 0 of 101 by the smallest base-10 palindrome not yet used; this is 202 (as 0 and 101 have been used before);
a(12) = 101 and we must now replace the last digit d = 1 of 101 by the smallest base-10 palindrome not yet used; this is 121; etc.
		

Crossrefs

Programs

  • Python
    from collections import deque
    from itertools import count, islice
    def pals(start=1): # generator of palindromes >= palindrome start
        s = str(start)
        q, r = divmod(len(s)+1, 2)
        for d in count(q):
            olst = [1, 0][int(d==q and r==1):]
            for offset in olst:
                lb = max(1, 10**(d-1)) if d>q or offset!=olst[0] else int(s[:q])
                for i in range(lb, 10**d):
                    left = str(i)
                    yield int(left+left[::-1][offset:])
    def agen(): # generator of terms
        S = deque([101])
        head = list(range(10)) + [11]
        yield from head
        used = set(head) | {101}
        pstart = {d:0 for d in "0123456789"}
        while True:
            an = S.popleft()
            yield an
            for d in str(an):
                p = next(p for p in pals(start=pstart[d]) if p not in used and d in str(p))
                pstart[d] = p
                S.append(p)
                used.add(p)
    print(list(islice(agen(), 57))) # Michael S. Branicky, Mar 03 2024

Extensions

More terms from Michael S. Branicky, Mar 03 2024