Skip to content

[Project Euler] Fix code style in Problem 55 #2985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions project_euler/problem_55/sol1.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
"""
Lychrel numbers
Problem 55: https://projecteuler.net/problem=55

If we take 47, reverse and add, 47 + 74 = 121, which is palindromic.

Not all numbers produce palindromes so quickly. For example,
349 + 943 = 1292,
1292 + 2921 = 4213
4213 + 3124 = 7337
That is, 349 took three iterations to arrive at a palindrome.

Although no one has proved it yet, it is thought that some numbers, like 196,
never produce a palindrome. A number that never forms a palindrome through the
reverse and add process is called a Lychrel number. Due to the theoretical nature
Expand Down Expand Up @@ -48,14 +53,14 @@ def sum_reverse(n: int) -> int:
return int(n) + int(str(n)[::-1])


def compute_lychrel_nums(limit: int) -> int:
def solution(limit: int = 10000) -> int:
"""
Returns the count of all lychrel numbers below limit.
>>> compute_lychrel_nums(10000)
>>> solution(10000)
249
>>> compute_lychrel_nums(5000)
>>> solution(5000)
76
>>> compute_lychrel_nums(1000)
>>> solution(1000)
13
"""
lychrel_nums = []
Expand All @@ -73,4 +78,4 @@ def compute_lychrel_nums(limit: int) -> int:


if __name__ == "__main__":
print(f"{compute_lychrel_nums(10000) = }")
print(f"{solution() = }")