Returns the product of a,b,c which are Pythagorean Triplet that satisfies the following: 1. a**2 + b**2 = c**2 2. a + b + c = 1000 >>> solution() 31875000
()
| 18 | |
| 19 | |
| 20 | def solution() -> int: |
| 21 | """ |
| 22 | Returns the product of a,b,c which are Pythagorean Triplet that satisfies |
| 23 | the following: |
| 24 | 1. a**2 + b**2 = c**2 |
| 25 | 2. a + b + c = 1000 |
| 26 | |
| 27 | >>> solution() |
| 28 | 31875000 |
| 29 | """ |
| 30 | |
| 31 | return next( |
| 32 | iter( |
| 33 | [ |
| 34 | a * b * (1000 - a - b) |
| 35 | for a in range(1, 999) |
| 36 | for b in range(a, 999) |
| 37 | if (a * a + b * b == (1000 - a - b) ** 2) |
| 38 | ] |
| 39 | ) |
| 40 | ) |
| 41 | |
| 42 | |
| 43 | if __name__ == "__main__": |