Move into 2022 folder

This commit is contained in:
Mark Hoekveen
2024-11-11 09:05:01 +01:00
parent 9dd6a4f275
commit e0d955ec6f
28 changed files with 5 additions and 11 deletions
+31
View File
@@ -0,0 +1,31 @@
# 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)