Advent of Code 2022: Day 2 Solutions
The time of the year has come when the Advent of Code begins!
I want to share with you my Python solutions to Day 2: Rock Paper Scissors puzzle:
with open('input') as file:
rounds = file.read().split('\n')
def solution_1():
return sum(
map(lambda round: {
'A X': 4,
'A Y': 8,
'A Z': 3,
'B X': 1,
'B Y': 5,
'B Z': 9,
'C X': 7,
'C Y': 2,
'C Z': 6
}.get(round), rounds)
)
def solution_2():
return sum(
map(lambda round: {
'A X': 3,
'B X': 1,
'C X': 2,
'A Y': 4,
'B Y': 5,
'C Y': 6,
'A Z': 8,
'B Z': 9,
'C Z': 7
}.get(round), rounds)
)
You can find the whole code here: https://github.com/Seishin/AoC2022
Happy coding! 👨💻
Comments ()