Couple more problems

This commit is contained in:
2016-02-05 21:54:01 -08:00
parent c80fb6f2a6
commit 73239e1c23
8 changed files with 229 additions and 0 deletions

19
problem_9.py Normal file
View File

@@ -0,0 +1,19 @@
#find the pythagorean triplet that a^2 + b^2 + c^2 = 1000
#just gonna do a nested for loop for this and brute force it
#it works, it's just slow as hell
def is_triplet(a, b, c):
if (a < b and b < c):
return True
else:
return False
for a in range(0, 999):
for b in range(0, 999):
for c in range(0, 999):
if is_triplet(a, b, c):
if a*a + b*b == c*c:
if (a+b+c == 1000):
print(a*b*c)
break