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.

A387199 Numbers which are not themselves palindromes, but a single swap of two digits creates a palindrome.

Original entry on oeis.org

110, 112, 113, 114, 115, 116, 117, 118, 119, 122, 133, 144, 155, 166, 177, 188, 199, 211, 220, 221, 223, 224, 225, 226, 227, 228, 229, 233, 244, 255, 266, 277, 288, 299, 311, 322, 330, 331, 332, 334, 335, 336, 337, 338, 339, 344, 355, 366, 377, 388, 399, 411, 422
Offset: 1

Views

Author

James S. DeArmon, Aug 21 2025

Keywords

Comments

Might be called "single-transposition palindromes".
Leading zeros are not allowed in either the initial number or the resultant palindrome.

Examples

			110 is a term since a swap of the second and third digits yields the palindrome 101.
		

Crossrefs

Cf. A002113.

Programs

  • Python
    def pal(s): return s == s[::-1]
    def swaps(s): yield from (t for i in range(len(s)-1) for j in range(i+1, len(s)) if (t:=s[:i]+s[j]+s[i+1:j]+s[i]+s[j+1:])[0]!='0')
    def ok(n): return not pal(s:=str(n)) and any(pal(t) for t in swaps(s))
    print([k for k in range(425) if ok(k)]) # Michael S. Branicky, Aug 22 2025

Extensions

More terms from Michael S. Branicky, Aug 22 2025