September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
|
|
@ -1,12 +1,10 @@
|
|||
from __future__ import division, print_function
|
||||
from math import sqrt
|
||||
from fractions import gcd
|
||||
from itertools import product
|
||||
from math import gcd, sqrt
|
||||
|
||||
|
||||
def hero(a, b, c):
|
||||
s = (a + b + c) / 2
|
||||
a2 = s*(s-a)*(s-b)*(s-c)
|
||||
a2 = s * (s - a) * (s - b) * (s - c)
|
||||
return sqrt(a2) if a2 > 0 else 0
|
||||
|
||||
|
||||
|
|
@ -20,12 +18,24 @@ def gcd3(x, y, z):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
maxside = 200
|
||||
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))
|
||||
print('\nFirst ten when ordered by increasing area, then perimeter,then maximum sides:')
|
||||
MAXSIDE = 200
|
||||
|
||||
N = 1 + MAXSIDE
|
||||
h = [(x, y, z)
|
||||
for x in range(1, N)
|
||||
for y in range(x, N)
|
||||
for z in range(y, N) if (x + y > z) and
|
||||
1 == gcd3(x, y, z) and
|
||||
is_heronian(x, y, z)]
|
||||
|
||||
# By increasing area, perimeter, then sides
|
||||
h.sort(key=lambda x: (hero(*x), sum(x), x[::-1]))
|
||||
|
||||
print(
|
||||
'Primitive Heronian triangles with sides up to %i:' % MAXSIDE, len(h)
|
||||
)
|
||||
print('\nFirst ten when ordered by increasing area, then perimeter,',
|
||||
'then maximum sides:')
|
||||
print('\n'.join(' %14r perim: %3i area: %i'
|
||||
% (sides, sum(sides), hero(*sides)) for sides in h[:10]))
|
||||
print('\nAll with area 210 subject to the previous ordering:')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue