We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ea0759d commit cc4f646Copy full SHA for cc4f646
project_euler/problem_09/sol1.py
@@ -23,11 +23,9 @@ def solution():
23
"""
24
for a in range(300):
25
for b in range(400):
26
- for c in range(500):
27
- if a < b < c:
28
- if (a ** 2) + (b ** 2) == (c ** 2):
29
- if (a + b + c) == 1000:
30
- return a * b * c
+ c = 1000 - a - b
+ if a < b < c and (a ** 2) + (b ** 2) == (c ** 2):
+ return a * b * c
31
32
33
if __name__ == "__main__":
project_euler/problem_09/sol3.py
@@ -25,11 +25,10 @@ def solution():
# 31875000
return [
- a * b * c
+ a * b * (1000 - a - b)
for a in range(1, 999)
for b in range(a, 999)
- for c in range(b, 999)
- if (a * a + b * b == c * c) and (a + b + c == 1000)
+ if (a * a + b * b == (1000 - a - b) ** 2)
][0]
34
35
0 commit comments