MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / solution

Function solution

project_euler/problem_009/sol1.py:20–38  ·  view source on GitHub ↗

Returns the product of a,b,c which are Pythagorean Triplet that satisfies the following: 1. a < b < c 2. a**2 + b**2 = c**2 3. a + b + c = 1000 >>> solution() 31875000

()

Source from the content-addressed store, hash-verified

18
19
20def solution() -> int:
21 """
22 Returns the product of a,b,c which are Pythagorean Triplet that satisfies
23 the following:
24 1. a < b < c
25 2. a**2 + b**2 = c**2
26 3. a + b + c = 1000
27
28 >>> solution()
29 31875000
30 """
31
32 for a in range(300):
33 for b in range(a + 1, 400):
34 for c in range(b + 1, 500):
35 if (a + b + c) == 1000 and (a**2) + (b**2) == (c**2):
36 return a * b * c
37
38 return -1
39
40
41def solution_fast() -> int:

Callers 1

sol1.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected