Что делает этот код?
python Код:
import math
def hypotenuses(n):
triples = []
for a in range(1, n):
for b in range(a, n):
c = math.sqrt(a**2 + b**2)
if c == int(c):
triples.append((a, b, int(c)))
hyps = {}
for t in triples:
hyp = t[2]
if hyp not in hyps:
hyps[hyp] = [t]
else:
hyps[hyp].append(t)
for h in hyps:
if len(hyps[h]) == 3:
print("Hypotenuse:", h)
for t in hyps[h]:
print(t)
hypotenuses(1000)