-
Notifications
You must be signed in to change notification settings - Fork 0
/
problem9.py
52 lines (31 loc) · 966 Bytes
/
problem9.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import time
import math
from mymodule import calculate_time
from mymodule import is_prime
#########################################################################3
def is_triangle(a, b, c):
return(a+b>c and b+c>a and a+c>b)
def triangle_from_perimeter(p):
solutions = []
for i in range(1, int(p/3)):
if (p**2 -2*p*i)%(2*p-2*i) == 0:
a = int((p**2 -2*p*i)/(2*p-2*i))
c = int(math.sqrt(a**2 + i**2))
if is_triangle(a, i, c):
solutions.append({a, i, c})
return solutions
def test():
return
#########################################################################3
@calculate_time
def main():
abc = triangle_from_perimeter(1000)
product = 1
for e in abc[0]:
product *= e
print(triangle_from_perimeter(1000))
print(product)
return 0
if __name__ == "__main__":
main()
test()