Skip to content

Commit a698fa9

Browse files
[Project Euler] Fix code style in Problem 55 (#2985)
* fix code style and update problem description with link Signed-off-by: joan.rosellr <[email protected]> * Update sol1.py Co-authored-by: Dhruv <[email protected]>
1 parent 40db8c2 commit a698fa9

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Diff for: project_euler/problem_55/sol1.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
"""
2+
Lychrel numbers
3+
Problem 55: https://projecteuler.net/problem=55
4+
25
If we take 47, reverse and add, 47 + 74 = 121, which is palindromic.
6+
37
Not all numbers produce palindromes so quickly. For example,
48
349 + 943 = 1292,
59
1292 + 2921 = 4213
610
4213 + 3124 = 7337
711
That is, 349 took three iterations to arrive at a palindrome.
12+
813
Although no one has proved it yet, it is thought that some numbers, like 196,
914
never produce a palindrome. A number that never forms a palindrome through the
1015
reverse and add process is called a Lychrel number. Due to the theoretical nature
@@ -48,14 +53,14 @@ def sum_reverse(n: int) -> int:
4853
return int(n) + int(str(n)[::-1])
4954

5055

51-
def compute_lychrel_nums(limit: int) -> int:
56+
def solution(limit: int = 10000) -> int:
5257
"""
5358
Returns the count of all lychrel numbers below limit.
54-
>>> compute_lychrel_nums(10000)
59+
>>> solution(10000)
5560
249
56-
>>> compute_lychrel_nums(5000)
61+
>>> solution(5000)
5762
76
58-
>>> compute_lychrel_nums(1000)
63+
>>> solution(1000)
5964
13
6065
"""
6166
lychrel_nums = []
@@ -73,4 +78,4 @@ def compute_lychrel_nums(limit: int) -> int:
7378

7479

7580
if __name__ == "__main__":
76-
print(f"{compute_lychrel_nums(10000) = }")
81+
print(f"{solution() = }")

0 commit comments

Comments
 (0)