Moved problems till 56 to Python.
This commit is contained in:
@@ -1,8 +1,24 @@
|
||||
from lib_misc import is_palindrome
|
||||
|
||||
|
||||
def get_digit_inverse(n):
|
||||
return int(str(n)[::-1])
|
||||
|
||||
|
||||
def is_not_lychrel(n, iterations=50):
|
||||
for i in range(0, iterations):
|
||||
n = n + get_digit_inverse(n)
|
||||
if is_palindrome(n):
|
||||
return (i + 1)
|
||||
return 0
|
||||
|
||||
|
||||
def euler_055():
|
||||
return 0
|
||||
lychrels = [n for n in range(1, 10000) if is_not_lychrel(n) == 0]
|
||||
s = len(lychrels)
|
||||
return s
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("e055.py: " + str(euler_055()))
|
||||
assert(euler_055() == 0)
|
||||
assert(euler_055() == 249)
|
||||
|
||||
Reference in New Issue
Block a user