In [1]:
def is_palindrome(s):
    s = str(s)
    L = len(s)
    for i in range(L/2):
        if s[i] != s[-(i+1)]:
            return False
        
    return True
assert is_palindrome('racecar')
assert is_palindrome('12321')
assert is_palindrome(12321)

def make_palindrome(n):
    s = str(n)
    L = len(s)
    
    for i in range(1,len(s)):
        s += s[L-i-1]
    
    return int(s)
assert make_palindrome(123) == 12321

def to_bin(n):
    return bin(n)[2:]
assert to_bin(123) == '1111011'

In [2]:
double_base_palindromes = []

for n in range(10**6):
    if not is_palindrome(n):
        continue
        
    pb = to_bin(n)
    if is_palindrome(pb):
        print n,pb
        double_base_palindromes.append(n)
print sum(double_base_palindromes)


0 0
1 1
3 11
5 101
7 111
9 1001
33 100001
99 1100011
313 100111001
585 1001001001
717 1011001101
7447 1110100010111
9009 10001100110001
15351 11101111110111
32223 111110111011111
39993 1001110000111001
53235 1100111111110011
53835 1101001001001011
73737 10010000000001001
585585 10001110111101110001
872187

In [ ]: