Move into 2022 folder
This commit is contained in:
@@ -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)
|
||||
Reference in New Issue
Block a user