Solve problem 86

main
Felix Martin 2021-04-21 12:14:57 -04:00
parent 0d650182d7
commit 8c80fdb3c1
1 changed files with 28 additions and 2 deletions

View File

@ -1,9 +1,35 @@
def shortest_path_squared(l, b, h):
s1 = l ** 2 + (h + b) ** 2
s2 = h ** 2 + (b + l) ** 2
s3 = b ** 2 + (h + l) ** 2
s = min(s1, s2, s3)
return s
def euler_086():
return 0
square_max = (10 ** 6) ** 2
squares = set([n * n for n in range(10**6)])
count = 0
m = 0
while True:
m += 1
cuboids = ((m, a, b)
for a in range(1, m + 1)
for b in range(1, a + 1))
for c in cuboids:
s = shortest_path_squared(*c)
if s in squares:
count += 1
if s > square_max:
raise Exception()
if count > 10 ** 6:
return m
if __name__ == "__main__":
solution = euler_086()
print("e086.py: " + str(solution))
assert(solution == 0)
assert(solution == 1818)