A380596 Numbers with embedded palindromes as proper substrings of the term.
100, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 122, 133, 144, 155, 166, 177, 188, 199, 200, 211, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 233, 244, 255, 266, 277, 288, 299, 300, 311, 322, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 344, 355, 366, 377, 388, 399
Offset: 1
Examples
100 is a term, since "00" is a palindrome; 1001 is a term for the same reason. 1020 is a term, since "020" is a palindrome; 10201 is a term for the same reason.
Programs
-
Python
from itertools import combinations def get_all_substrings(string): length = len(string) + 1 return [string[x:y] for x, y in combinations(range(length), r=2)] def is_palindrome(n): return str(n) == str(n)[::-1] def ok(n): subsets = get_all_substrings(str(n)) subsets = [subset for subset in subsets if is_palindrome(subset) and len(subset)>1 and len(subset)
0 print([k for k in range (100,400) if ok(k)]) -
Python
def ok(n): s = str(n) return any(p == p[::-1] and len(p) < len(s) for p in (s[i:i+j] for j in (2, 3) for i in range(len(s)-j+1))) print([k for k in range(400) if ok(k)]) # Michael S. Branicky, Feb 08 2025
Comments