From a698fa9a3fd11f2b2fa2ec8209fc29fcc799de04 Mon Sep 17 00:00:00 2001 From: Joan Date: Wed, 7 Oct 2020 17:09:36 +0200 Subject: [PATCH] [Project Euler] Fix code style in Problem 55 (#2985) * fix code style and update problem description with link Signed-off-by: joan.rosellr * Update sol1.py Co-authored-by: Dhruv --- 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 a2e27bbb9..14e411541 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(f"{solution() = }")