20 lines
416 B
Python
20 lines
416 B
Python
from lib_misc import is_palindrome
|
|
|
|
|
|
def is_palindrome_binary(n):
|
|
return is_palindrome(str(bin(n)[2:]))
|
|
|
|
|
|
def is_palindrome_decimal(n):
|
|
return is_palindrome(str(n))
|
|
|
|
|
|
def euler_036():
|
|
return sum([i for i in range(1000000)
|
|
if is_palindrome_decimal(i) and is_palindrome_binary(i)])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
print("e036.py: {}".format(euler_036()))
|
|
assert(euler_036() == 872187)
|