This commit is contained in:
Michael Zhang 2022-12-02 09:10:28 -06:00
parent 663fb5d574
commit fe5975b34c
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
2 changed files with 2552 additions and 0 deletions

51
02.py Normal file
View file

@ -0,0 +1,51 @@
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)

2501
02.txt Normal file

File diff suppressed because it is too large Load diff