-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path68.py
37 lines (32 loc) · 978 Bytes
/
68.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
import itertools
def test(A, B, C, D, E, F, G, H, I, J, suma):
comb = [(A, B, C), (D, C, E), (F, E, G), (H, G, I), (J, I, B)]
for i in comb:
if sum(i) != suma:
return ()
return comb
def exist(slays, all):
for i in all:
if slays in i:
return True
return False
all = []
chifri = list(range(1, 10+1))
for summma in range(6, 27+1):
for i in itertools.permutations(chifri):
A, B, C, D, E, F, G, H, I, J = i
result = test(A, B, C, D, E, F, G, H, I, J, summma)
if result != () and not exist(result[0], all) and not exist(result[1], all) \
and not exist(result[2], all) and not exist(result[3], all) \
and not exist(result[4], all):
all.append(result)
print(all)
m = []
for i in all:
s = ""
for j in i:
s += "".join([str(x) for x in j])
if len(s) == 16:
m.append(int(s))
print("Otvet =", max(m))
print(m)