36 lines
760 B
Python
36 lines
760 B
Python
from itertools import permutations
|
|
data = open(0).read().strip()
|
|
|
|
part_2 = False
|
|
|
|
people = set()
|
|
scores = {}
|
|
for line in data.splitlines():
|
|
a, _, wl, score, _, _, _, _, _, _, b = line.split()
|
|
b = b.replace(".", "")
|
|
score = int(score)
|
|
if wl == "lose":
|
|
score = -score
|
|
people.add(a)
|
|
people.add(b)
|
|
scores[(a, b)] = score
|
|
if part_2:
|
|
scores[(a, "me")] = 0
|
|
scores[("me", a)] = 0
|
|
scores[(b, "me")] = 0
|
|
scores[("me", b)] = 0
|
|
|
|
if part_2:
|
|
people.add("me")
|
|
|
|
max_score = 0
|
|
for p in permutations(list(people)):
|
|
s = 0
|
|
for i in range(len(p)):
|
|
a, b = p[i], p[(i + 1) % len(p)]
|
|
s += scores[(a, b)]
|
|
s += scores[(b, a)]
|
|
max_score = max(max_score, s)
|
|
|
|
print(max_score)
|