diff --git a/project_euler/problem_04/sol1.py b/project_euler/problem_04/sol1.py index 227b594d0..42f56f3ef 100644 --- a/project_euler/problem_04/sol1.py +++ b/project_euler/problem_04/sol1.py @@ -8,7 +8,7 @@ is less than N. """ -def solution(n): +def solution(n: int = 998001) -> int: """Returns the largest palindrome made from the product of two 3-digit numbers which is less than n. diff --git a/project_euler/problem_04/sol2.py b/project_euler/problem_04/sol2.py index 0f185f121..8ee082ad2 100644 --- a/project_euler/problem_04/sol2.py +++ b/project_euler/problem_04/sol2.py @@ -8,7 +8,7 @@ is less than N. """ -def solution(n): +def solution(n: int = 998001) -> int: """Returns the largest palindrome made from the product of two 3-digit numbers which is less than n. @@ -22,8 +22,8 @@ def solution(n): answer = 0 for i in range(999, 99, -1): # 3 digit numbers range from 999 down to 100 for j in range(999, 99, -1): - t = str(i * j) - if t == t[::-1] and i * j < n: + product_string = str(i * j) + if product_string == product_string[::-1] and i * j < n: answer = max(answer, i * j) return answer