Files
aoc-2022/2022/2/twostar.py
T
2024-11-11 09:05:01 +01:00

32 lines
752 B
Python

# X means you need to lose,
# Y means you need to end the round in a draw,
# and Z means you need to win. Good luck!"
scores = {
"A": 1, #Rock
"B": 2, #Paper
"C": 3 #Scissors
}
score = 0
with open("input.txt", "r") as f:
for line in f.readlines():
strategy = line.strip("\n").split(" ")
theirs = scores[strategy[0]]
victory = strategy[1]
ours = 0
if victory == "X": # Lose
ours = theirs-1
elif victory == "Y": # Draw
ours = theirs
score += 3
elif victory == "Z": # Win
ours = theirs+1
score += 6
if ours == 0:
ours = 3
if ours > 3:
ours = 1
score += ours
print(score)