-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathXtremeFakeCoins.py
57 lines (45 loc) · 1.38 KB
/
XtremeFakeCoins.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
import sys
import itertools
alpha = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
#m_file = open("fake_coins_in.txt","r")
firstline = sys.stdin.readline().strip()
N = int(firstline.split(",")[0])
M = int(firstline.split(",")[1])
experiments = []
for line in sys.stdin:
line = line.strip()
experiments.append(line.split("-"))
def ret_experiment(letA,letB):
results = []
results.append("9")
for experiment in experiments:
if letA in experiment[0] and letB not in experiment[1]:
results.append("0")
elif letA in experiment[1] and letB not in experiment[0]:
results.append("2")
elif letB in experiment[0] and letA not in experiment[1]:
results.append("0")
elif letB in experiment[1] and letA not in experiment[0]:
results.append("2")
else:
results.append("1")
return int("".join(results))
alpha_reduced = alpha[:N]
combos = [x for x in itertools.combinations(alpha_reduced,2)]
combo_dict = {}
for combo in combos:
key = ret_experiment(combo[0],combo[1])
val = combo[0] + combo[1]
if key in combo_dict:
combo_dict[key].append(val)
else:
combo_dict[key] = [val]
fin_list = []
for key in combo_dict:
if len(combo_dict[key]) > 1:
fin_combos = [x for x in itertools.combinations(combo_dict[key],2)]
for x in fin_combos:
fin_list.append(x[0] + "=" + x[1])
fin_list.sort()
for x in fin_list:
print(x)