mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-03-20 05:29:48 +00:00
Improve Project Euler problem 009 solution 1 (#4749)
* Improve solution * Uncomment code that has been commented due to slow execution affecting Travis
This commit is contained in:
parent
4761fef1a5
commit
a7b9e28bc3
@ -25,18 +25,16 @@ def solution() -> int:
|
|||||||
2. a**2 + b**2 = c**2
|
2. a**2 + b**2 = c**2
|
||||||
3. a + b + c = 1000
|
3. a + b + c = 1000
|
||||||
|
|
||||||
# The code below has been commented due to slow execution affecting Travis.
|
>>> solution()
|
||||||
# >>> solution()
|
31875000
|
||||||
# 31875000
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for a in range(300):
|
for a in range(300):
|
||||||
for b in range(400):
|
for b in range(a + 1, 400):
|
||||||
for c in range(500):
|
for c in range(b + 1, 500):
|
||||||
if a < b < c:
|
if (a + b + c) == 1000:
|
||||||
if (a ** 2) + (b ** 2) == (c ** 2):
|
if (a ** 2) + (b ** 2) == (c ** 2):
|
||||||
if (a + b + c) == 1000:
|
return a * b * c
|
||||||
return a * b * c
|
|
||||||
|
|
||||||
|
|
||||||
def solution_fast() -> int:
|
def solution_fast() -> int:
|
||||||
@ -47,9 +45,8 @@ def solution_fast() -> int:
|
|||||||
2. a**2 + b**2 = c**2
|
2. a**2 + b**2 = c**2
|
||||||
3. a + b + c = 1000
|
3. a + b + c = 1000
|
||||||
|
|
||||||
# The code below has been commented due to slow execution affecting Travis.
|
>>> solution_fast()
|
||||||
# >>> solution_fast()
|
31875000
|
||||||
# 31875000
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for a in range(300):
|
for a in range(300):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user