46 lines
1016 B
Python
46 lines
1016 B
Python
# A for Rock, B for Paper, and C for Scissors.
|
|
# X for Rock, Y for Paper, and Z for Scissors.
|
|
|
|
# shape you selected (1 for Rock, 2 for Paper, and 3 for Scissors)
|
|
# plus the score for the outcome of the round (0 if you lost, 3 if the round was a draw, and 6 if you won).
|
|
|
|
points = {
|
|
"X": 1,
|
|
"Y": 2,
|
|
"Z": 3,
|
|
}
|
|
|
|
convert = dict(A="X", B="Y", C="Z")
|
|
|
|
win = dict(A="Y", B="Z", C="X")
|
|
lose = dict(A="Z", B="X", C="Y")
|
|
|
|
# def win(a, b):
|
|
# return (a == "A" and b == "Y") or (a == "B" and b == "Z") or (a == "C" and b == "X")
|
|
|
|
|
|
# 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!"
|
|
|
|
|
|
score = 0
|
|
|
|
|
|
with open("input.txt") as f:
|
|
for line in f:
|
|
c1, c2 = line.split()
|
|
|
|
if c2 == "X": # lose
|
|
pick = lose[c1]
|
|
elif c2 == "Y": # draw
|
|
pick = convert[c1]
|
|
score += 3
|
|
elif c2 == "Z": # win
|
|
pick = win[c1]
|
|
score += 6
|
|
|
|
score += points[pick]
|
|
|
|
|
|
print(score) |