Skip to content

Commit 36cc80e

Browse files
archaengelstokhos
authored andcommitted
Add style improvements to solutions for Project Euler Problem 04 (TheAlgorithms#2945)
* Fix typehints in project_euler/problem01 Squashed commit of the following: commit 6801d07 Author: Archaengel <[email protected]> Date: Mon Oct 5 16:40:10 2020 -0700 Fix typehints in project_euler/problem01 commit 29afc3a Author: Archaengel <[email protected]> Date: Mon Oct 5 15:06:34 2020 -0700 Add typehints and default argument for project_euler/problem_01 * Add default args, typehints, and expand variable names for PE prob 02 * Add style improvements for first solution of PE Problem 02 * Add default arg and typehints for second solution of PE Problem 02 * Add default arg for third solution of PE Problem 02 * Add style improvements for 1st soln of PE problem 03 * Add default arg and typehints for 2nd soln of PE problem 03 * Add default arg for 3rd soln of PE problem 03 * Remove unnecessary newlines * Remove unnecessary newlines * Fix end of file for 2nd soln in PE problem 03 * Add style improvements to solutions for PE problem 04 * Restore original newlines in soln for PE problem 04 * Fix punctuation in docstring for PE problem 04 * Restore solution bodies for PE problem 04 * Expand variable names for 2nd soln of PE problem 04
1 parent 273cc2e commit 36cc80e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Diff for: project_euler/problem_04/sol1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"""
99

1010

11-
def solution(n):
11+
def solution(n: int = 998001) -> int:
1212
"""Returns the largest palindrome made from the product of two 3-digit
1313
numbers which is less than n.
1414

Diff for: project_euler/problem_04/sol2.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"""
99

1010

11-
def solution(n):
11+
def solution(n: int = 998001) -> int:
1212
"""Returns the largest palindrome made from the product of two 3-digit
1313
numbers which is less than n.
1414
@@ -22,8 +22,8 @@ def solution(n):
2222
answer = 0
2323
for i in range(999, 99, -1): # 3 digit numbers range from 999 down to 100
2424
for j in range(999, 99, -1):
25-
t = str(i * j)
26-
if t == t[::-1] and i * j < n:
25+
product_string = str(i * j)
26+
if product_string == product_string[::-1] and i * j < n:
2727
answer = max(answer, i * j)
2828
return answer
2929

0 commit comments

Comments
 (0)