euler/python/e036.py

20 lines
416 B
Python
Raw Normal View History

2019-07-17 03:17:08 +02:00
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))
2019-07-16 19:43:08 +02:00
def euler_036():
2019-07-17 03:17:08 +02:00
return sum([i for i in range(1000000)
if is_palindrome_decimal(i) and is_palindrome_binary(i)])
2019-07-16 19:43:08 +02:00
if __name__ == "__main__":
print("e036.py: {}".format(euler_036()))
2019-07-17 03:17:08 +02:00
assert(euler_036() == 872187)