1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
from itertools import combinations c, triangles = 10, [] # find all acute triangles with side lengths # a, b and c with c equal to 10 and a < b for a in range(1, 14): for b in range(a + 1, 14): # ensure that the sides can make a triangle if a + b > 10 or b - a < 10: # ensure that the triangle is acute if a * a + b * b + c * c > 2 * max(a, b, c) ** 2: # and this triangle to our list triangles += [(a, b)] # combine triangles four at a time for comb in combinations(triangles, 4): # find the set of eight side lengths sides = {y for x in comb for y in x} # the sides must all be different lengths, lengths of 1 and 13 # must be present and the average length must be an integer if len(sides) == 8 and {1, 13} < sides and sum(sides) % 8 == 0: print(tuple(sorted(sides)), sum(sides) // 8, comb) |