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:
Maxim Smolskiy 2021-09-21 14:28:27 +03:00 committed by GitHub
parent 4761fef1a5
commit a7b9e28bc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,17 +25,15 @@ def solution() -> int:
2. a**2 + b**2 = c**2
3. a + b + c = 1000
# The code below has been commented due to slow execution affecting Travis.
# >>> solution()
# 31875000
>>> solution()
31875000
"""
for a in range(300):
for b in range(400):
for c in range(500):
if a < b < c:
if (a ** 2) + (b ** 2) == (c ** 2):
for b in range(a + 1, 400):
for c in range(b + 1, 500):
if (a + b + c) == 1000:
if (a ** 2) + (b ** 2) == (c ** 2):
return a * b * c
@ -47,9 +45,8 @@ def solution_fast() -> int:
2. a**2 + b**2 = c**2
3. a + b + c = 1000
# The code below has been commented due to slow execution affecting Travis.
# >>> solution_fast()
# 31875000
>>> solution_fast()
31875000
"""
for a in range(300):