""" Part2 """ 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": "LOSS", "Y": "DRAW", "Z": "WIN", } BETTER_THAN = { "ROCK": "PAPER", "PAPER": "SCISSORS", "SCISSORS": "ROCK", } WORSE_THAN = {"ROCK": "SCISSORS", "PAPER": "ROCK", "SCISSORS": "PAPER"} score = 0 for line in file.readlines(): line = line.strip() opponent, outcome = line.split(" ") opponent = MAPPINGS[opponent] outcome = MAPPINGS[outcome] score_this_round = 0 score_this_round += SCORES[outcome] if outcome == "WIN": ours = BETTER_THAN[opponent] elif outcome == "DRAW": ours = opponent else: ours = WORSE_THAN[opponent] score_this_round += SCORES[ours] print("opp:", opponent, "our", ours) score += score_this_round print(outcome, "Score:", score_this_round) print() print() print(score)