From b8116423fb17f5134dae7d207e8eb92010afb29f Mon Sep 17 00:00:00 2001 From: "joan.rosellr" Date: Wed, 7 Oct 2020 16:27:38 +0200 Subject: [PATCH 1/2] fix code style and update problem description with link Signed-off-by: joan.rosellr --- project_euler/problem_55/sol1.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/project_euler/problem_55/sol1.py b/project_euler/problem_55/sol1.py index a2e27bbb9e93..fbbc88e71eee 100644 --- a/project_euler/problem_55/sol1.py +++ b/project_euler/problem_55/sol1.py @@ -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 @@ -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 = [] @@ -73,4 +78,4 @@ def compute_lychrel_nums(limit: int) -> int: if __name__ == "__main__": - print(f"{compute_lychrel_nums(10000) = }") + print(solution(int(input("Enter a number: ").strip()))) From a42aef807885e13fff4f7afcace2c36f560ef4f6 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Wed, 7 Oct 2020 20:34:04 +0530 Subject: [PATCH 2/2] Update sol1.py --- project_euler/problem_55/sol1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project_euler/problem_55/sol1.py b/project_euler/problem_55/sol1.py index fbbc88e71eee..14e411541f3a 100644 --- a/project_euler/problem_55/sol1.py +++ b/project_euler/problem_55/sol1.py @@ -78,4 +78,4 @@ def solution(limit: int = 10000) -> int: if __name__ == "__main__": - print(solution(int(input("Enter a number: ").strip()))) + print(f"{solution() = }")