42 lines
840 B
Python
42 lines
840 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(X="A", Y="B", Z="C")
|
|
|
|
|
|
def win(a, b):
|
|
return (a == "A" and b == "Y") or (a == "B" and b == "Z") or (a == "C" and b == "X")
|
|
|
|
|
|
|
|
score = 0
|
|
with open("input.txt") as f:
|
|
for line in f:
|
|
c1, c2 = line.split()
|
|
score += points[c2]
|
|
if c1 == convert[c2]:
|
|
# print("draw")
|
|
score += 3
|
|
elif win(c1, c2):
|
|
# print("win")
|
|
score += 6
|
|
else:
|
|
# print("lose")
|
|
pass
|
|
|
|
# print(score)
|
|
|
|
|
|
print(score) |