-
Notifications
You must be signed in to change notification settings - Fork 0
/
p075.py
60 lines (40 loc) · 1.07 KB
/
p075.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
53
54
55
56
from functions import pythTriplet
# It seems that the perimeter of a primitive pythagorean triplet is:
# m*m + 2*m*n + m*m = 2mm + 2mn
sol_count = 0
LEN_WIRE = 50
UPPER_LIMIT = int((LEN_WIRE**0.5) + 1)
solutions = set()
checked_already = set()
for m in range(2, UPPER_LIMIT):
for n in range(1, m): # n cannot be equal to m
tmp = 2*m*m + 2*m*n
val = tmp
while tmp <= LEN_WIRE:
if tmp == 24:
print('AA', m, n)
if tmp > LEN_WIRE:
break
if (tmp in solutions) and (tmp in checked_already):
tmp += val
continue
if (tmp in solutions):
checked_already.add(tmp)
sol_count -= 1
tmp += val
continue
solutions.add(tmp)
sol_count += 1
tmp += val
print(sol_count)
print(len(solutions))
print(len(checked_already))
for x in solutions:
print('solution', x)
for x in checked_already:
print('c-a', x)
"""
3, 4, 5
6, 8, 10
8, 6, 10
"""