A387199 Numbers which are not themselves palindromes, but a single swap of two digits creates a palindrome.
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
Examples
110 is a term since a swap of the second and third digits yields the palindrome 101.
Links
- Michael S. Branicky, Table of n, a(n) for n = 1..10000
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
Comments