Anonymous user
Heronian triangles: Difference between revisions
→{{header|Python}}: Tidy.
(New draft task and Python solution.) |
(→{{header|Python}}: Tidy.) |
||
Line 31:
=={{header|Python}}==
<lang python>from math import sqrt
Line 42 ⟶ 41:
def is_heronian(a, b, c):
a = hero(a, b, c)
return a
Line 53 ⟶ 52:
h = [(a, b, c) for a,b,c in product(range(1, maxside + 1), repeat=3)
if a <= b <= c and a + b > c and gcd3(a, b, c) == 1 and is_heronian(a, b, c)]
h.sort(key = lambda x: (hero(*x), sum(x), x[::-1])) # By increasing area, perimeter, then sides
print('Primitive Heronian triangles with sides up to %i:' % maxside, len(h))
|