-
Notifications
You must be signed in to change notification settings - Fork 0
/
Prob_39_unsolved.py
64 lines (52 loc) · 1.59 KB
/
Prob_39_unsolved.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
57
58
59
60
61
62
63
64
import operator
# Integer Right Triangles
# Implementing stupid brute force trials:
def brute_force_triangle_check(max_perim):
for p in range(3, max_perim + 1):
for a in range(1, p - 2):
b = 0.5*(p - a)
c = 0.5*(p - a)
def is_perfect_square(num):
return (int(num**(1/2)))**2 == num
# perimeter_length_solutions = {}
#
#
# def len_hyp(a, b):
# return (a**2 + b**2)**(1/2)
#
#
# def check_right_triangle(kat1, kat2, hyp):
# return kat1**2 + kat2**2 - hyp**2 == 0
#
#
# base_pairs = []
# triangle_perimeter = 125
#
# # Real part of the imaginary number
# a = 2
#
#
# while a**2 + a < triangle_perimeter - 2:
# # Complex part of the imaginary number
# b = 1
# while b < a:
# if (a, b) not in base_pairs and (b, a) not in base_pairs:
# base_pairs.append((a, b))
# base_pairs.append((b, a))
# perim = (a**2 - b**2) + 2*a*b + (len_hyp(a, b))
# if perim in perimeter_length_solutions.keys():
# perimeter_length_solutions[perim] += 1
# else:
# perimeter_length_solutions[perim] = 1
#
# b += 1
#
# # Ønsker å implementere skalering av triplettene som dannes ved multiplisere (a + ib) med seg selv.
#
# a += 1
#
#
# max_key = max(perimeter_length_solutions.keys(), key=lambda k: perimeter_length_solutions[k])
#
# print("The perimeter value with the most amount of solutions was: {}\nWith {} solutions"
# .format(max_key, perimeter_length_solutions[max_key]))