Finished 9, easy brute force solution
This commit is contained in:
28
9/main.py
Normal file
28
9/main.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import os
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Find the pythagorean triplet that sums to 1000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def checkPythTriplet(a, b, c):
|
||||||
|
return pow(a, 2) + pow(b, 2) == pow(c, 2)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
print("Hello, this is Patrick")
|
||||||
|
|
||||||
|
|
||||||
|
for b in range(500):
|
||||||
|
for a in range(b):
|
||||||
|
c = 1000 - b - a
|
||||||
|
|
||||||
|
if b < c and checkPythTriplet(a, b, c):
|
||||||
|
print(a, b, c, a*b*c)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user