login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Numbers for which in base 2 the least number of digits that can be removed to leave a palindrome (possibly beginning with 0) is 2.
4

%I #11 Aug 24 2021 07:52:31

%S 12,20,24,26,28,38,39,40,44,48,50,57,58,60,68,70,71,72,74,75,78,79,80,

%T 84,86,87,92,96,98,100,105,106,108,110,113,117,118,121,122,124,132,

%U 134,135,138,139,140,141,144,152,154,155,158,159,160,164,166,167,172

%N Numbers for which in base 2 the least number of digits that can be removed to leave a palindrome (possibly beginning with 0) is 2.

%H Robert Israel, <a href="/A050421/b050421.txt">Table of n, a(n) for n = 1..10000</a>

%e (20 base 2) = 101000 -> 0000.

%p filter:= proc(n) local L,R,k,m;

%p L:= convert(n,base,2);

%p R:= ListTools:-Reverse(L);

%p m:= nops(L);

%p if L = R then return false fi;

%p if ormap(i -> subsop(i=NULL,L)=subsop(m+1-i=NULL,R), [$1..m]) then return false fi;

%p ormap(p -> subsop(p[1]=NULL,subsop(p[2]=NULL,L))=subsop(m-p[1]=NULL,subsop(m+1-p[2]=NULL,R)), [seq(seq([i,j],j=i+1..m),i=1..m-1)])

%p end proc:

%p select(filter, [$4..200]); # _Robert Israel_, Oct 28 2020

%o (Python)

%o from itertools import combinations

%o def ok(n):

%o b = bin(n)[2:]

%o for digs_to_remove in range(4):

%o for skip in combinations(range(len(b)), digs_to_remove):

%o newb = "".join(b[i] for i in range(len(b)) if i not in skip)

%o if len(newb) > 0 and newb == newb[::-1]:

%o return (digs_to_remove == 2)

%o return False

%o print(list(filter(ok, range(173)))) # _Michael S. Branicky_, Aug 24 2021

%Y Cf. A050426, A050420, A050422, A050423, A050424.

%K nonn,base

%O 1,1

%A _Clark Kimberling_