You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
936 B
Python
54 lines
936 B
Python
"""
|
|
Part1
|
|
"""
|
|
|
|
file = open("input/input", "r", encoding="utf-8")
|
|
|
|
SCORES = {"ROCK": 1, "PAPER": 2, "SCISSORS": 3, "WIN": 6, "DRAW": 3, "LOSS": 0}
|
|
|
|
MAPPINGS = {
|
|
"A": "ROCK",
|
|
"B": "PAPER",
|
|
"C": "SCISSORS",
|
|
"X": "ROCK",
|
|
"Y": "PAPER",
|
|
"Z": "SCISSORS",
|
|
}
|
|
|
|
BETTER_THAN = {
|
|
"ROCK": "PAPER",
|
|
"PAPER": "SCISSORS",
|
|
"SCISSORS": "ROCK",
|
|
}
|
|
|
|
score = 0
|
|
|
|
for line in file.readlines():
|
|
line = line.strip()
|
|
opponent, ours = line.split(" ")
|
|
|
|
opponent = MAPPINGS[opponent]
|
|
ours = MAPPINGS[ours]
|
|
|
|
score_this_round = 0
|
|
score_this_round += SCORES[ours]
|
|
|
|
print("opp:", opponent, "our", ours)
|
|
|
|
if opponent == ours:
|
|
outcome = "DRAW"
|
|
elif ours == BETTER_THAN[opponent]:
|
|
outcome = "WIN"
|
|
else:
|
|
outcome = "LOSS"
|
|
|
|
score_this_round += SCORES[outcome]
|
|
score += score_this_round
|
|
|
|
print(outcome, "Score:", score_this_round)
|
|
print()
|
|
|
|
|
|
print()
|
|
print(score)
|