52 lines
799 B
Python
52 lines
799 B
Python
|
from typing import Dict, Tuple
|
||
|
|
||
|
|
||
|
data = """
|
||
|
A Y
|
||
|
B X
|
||
|
C Z
|
||
|
""".strip().splitlines()
|
||
|
|
||
|
|
||
|
with open("02.txt") as f:
|
||
|
data = f.readlines()
|
||
|
pass
|
||
|
|
||
|
res: Dict[Tuple[str, str], int] = {
|
||
|
("A", "X"): 3,
|
||
|
("B", "Y"): 3,
|
||
|
("C", "Z"): 3,
|
||
|
|
||
|
("A", "Z"): 0,
|
||
|
("B", "X"): 0,
|
||
|
("C", "Y"): 0,
|
||
|
|
||
|
("A", "Y"): 6,
|
||
|
("B", "Z"): 6,
|
||
|
("C", "X"): 6,
|
||
|
}
|
||
|
|
||
|
s = 0
|
||
|
for l in data:
|
||
|
a, b = l.strip().split(" ")
|
||
|
s1 = dict(X = 1, Y = 2, Z = 3)[b]
|
||
|
s2 = res[a, b]
|
||
|
print(s1, s2)
|
||
|
s += s1 + s2
|
||
|
|
||
|
print(s)
|
||
|
|
||
|
s = 0
|
||
|
for l in data:
|
||
|
a, b = l.strip().split(" ")
|
||
|
s1 = dict(X = 0, Y = 3, Z = 6)[b]
|
||
|
for c in "XYZ":
|
||
|
if res[a, c] == s1:
|
||
|
r1 = dict(X = 1, Y = 2, Z = 3)[c]
|
||
|
r2 = s1
|
||
|
print(r1, r2)
|
||
|
s += r1 + r2
|
||
|
continue
|
||
|
|
||
|
print(s)
|