Add style improvements to solutions for Project Euler Problem 04 (#2945)

* Fix typehints in project_euler/problem01

Squashed commit of the following:

commit 6801d073b31bf702814861cd3b07b634ca295bfa
Author: Archaengel <god11341258@gmail.com>
Date:   Mon Oct 5 16:40:10 2020 -0700

    Fix typehints in project_euler/problem01

commit 29afc3af114abd1b99dc3f7c8fc99128229db131
Author: Archaengel <god11341258@gmail.com>
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
This commit is contained in:
Edward Nuno 2020-10-06 22:03:34 -07:00 committed by GitHub
parent ddf83ec886
commit a5000d32ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -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 """Returns the largest palindrome made from the product of two 3-digit
numbers which is less than n. numbers which is less than n.

View File

@ -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 """Returns the largest palindrome made from the product of two 3-digit
numbers which is less than n. numbers which is less than n.
@ -22,8 +22,8 @@ def solution(n):
answer = 0 answer = 0
for i in range(999, 99, -1): # 3 digit numbers range from 999 down to 100 for i in range(999, 99, -1): # 3 digit numbers range from 999 down to 100
for j in range(999, 99, -1): for j in range(999, 99, -1):
t = str(i * j) product_string = str(i * j)
if t == t[::-1] and i * j < n: if product_string == product_string[::-1] and i * j < n:
answer = max(answer, i * j) answer = max(answer, i * j)
return answer return answer