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_fast() 31875000
()
| 39 | |
| 40 | |
| 41 | def solution_fast() -> int: |
| 42 | """ |
| 43 | Returns the product of a,b,c which are Pythagorean Triplet that satisfies |
| 44 | the following: |
| 45 | 1. a < b < c |
| 46 | 2. a**2 + b**2 = c**2 |
| 47 | 3. a + b + c = 1000 |
| 48 | |
| 49 | >>> solution_fast() |
| 50 | 31875000 |
| 51 | """ |
| 52 | |
| 53 | for a in range(300): |
| 54 | for b in range(400): |
| 55 | c = 1000 - a - b |
| 56 | if a < b < c and (a**2) + (b**2) == (c**2): |
| 57 | return a * b * c |
| 58 | |
| 59 | return -1 |
| 60 | |
| 61 | |
| 62 | def benchmark() -> None: |
nothing calls this directly
no outgoing calls
no test coverage detected