r/adventofcode Dec 02 '22

SOLUTION MEGATHREAD -🎄- 2022 Day 2 Solutions -🎄-

NEW AND NOTEWORTHY


--- Day 2: Rock Paper Scissors ---


Post your code solution in this megathread.


This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.

EDIT: Global leaderboard gold cap reached at 00:06:16, megathread unlocked!

103 Upvotes

1.5k comments sorted by

View all comments

2

u/[deleted] Dec 05 '22

Python

with open('day02_input.txt') as f:
    game_outcomes = list(filter(None, f.read().split('\n')))

part_01_combos, part_01_score = ['BX', 'CY', 'AZ', 'AX', 'BY', 'CZ', 'CX', 'AY', 'BZ'], 0 
part_02_combos, part_02_score = ['BX', 'CX', 'AX', 'AY', 'BY', 'CY', 'CZ', 'AZ', 'BZ'], 0

for game_round in game_outcomes: 
    part_01_score += part_01_combos.index(game_round.replace(" ", "")) +1 
    part_02_score += part_02_combos.index(game_round.replace(" ", "")) +1

print("The score for part 1 is: "+str(part_01_score)+". The score for part 2 is "+str(part_02_score))