From 03bb8d283fedfed5d8c70698a14cb7917f8dd414 Mon Sep 17 00:00:00 2001 From: Philippe Zwietering Date: Tue, 31 Mar 2020 00:46:27 +0200 Subject: [PATCH] Finished 9, easy brute force solution --- 9/main.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 9/main.py diff --git a/9/main.py b/9/main.py new file mode 100644 index 0000000..ef1fee7 --- /dev/null +++ b/9/main.py @@ -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() \ No newline at end of file