12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- # https://adventofcode.com/2022/day/2
-
- MOVE_SCORES = {
- "A": 1,
- "B": 2,
- "C": 3,
- "X": 1,
- "Y": 2,
- "Z": 3
- }
-
- MOVE_BEATS = {
- "X": "C",
- "Y": "A",
- "Z": "B"
- }
-
- MOVE_EQUALS = {
- "X": "A",
- "Y": "B",
- "Z": "C"
- }
-
- def main():
- with open("input2.txt", "r") as file:
- moves = [line.strip() for line in file.readlines()]
-
- # moves = [(x, y) for line in inlines for x, y in line.split(" ")]
-
- scores = []
- for move in moves:
- (theirs, mine) = move.split(" ")
- cur_score = MOVE_SCORES[mine]
- if MOVE_BEATS[mine] == theirs:
- cur_score += 6
- elif MOVE_EQUALS[mine] == theirs:
- cur_score += 3
- scores.append(cur_score)
-
- print(sum(scores))
-
- if __name__ == "__main__":
- main()
|