This one was quick and simple. Any optimizations?
from timeit import default_timer as timer
def sum_double_base_palindromes_under(limit):
def is_palindrome(n):
if str(n) == str(n)[::-1]:
return True
return False
sum = 0
for n in range(limit):
if is_palindrome(n) and is_palindrome(int(bin(n)[2:])):
sum += n
return sum
start = timer()
ans = sum_double_base_palindromes_under(1000000)
elapsed_time = (timer() - start) * 1000 # s --> ms
print "Found %d in %r ms." % (ans, elapsed_time)