AOC 2022 — Day 2

Matt E.
5 min readJan 12, 2023

Today I’ll detail my solution for the second challenge of the Advent of Code 2022. If you don’t know what that is, I’ll send you towards the presentation in Day 1

The Elves begin to set up camp on the beach. They organise a giant tournament of Rock Paper Scissors to decide who will be closest to the food.

In case you need a reminder of the rules, you can find them here.

To win the tournament, you need to end up with the highest score. Here how the score are computed for each round :

So if you win with Rock, you get 7 points. If you lose with Scissors you get 3 points and so on.

Part 1

An elf gives you a strategy guide. The first columns represent your opponent’s move, but before he finishes his explanation, you’re interrupted and he has to go.

You suppose the second column is the move you need to choose.

The goal for this challenge is to compute the score you will have at the end of the tournament if you follow the strategy guide.


You receive an input in the following format :

In this example, the strategy guides means :

  • In the first round, your opponent plays Rock and you choose paper.
    So you win with 8 points.
  • In the second round, your opponent plays Paper and you choose Rock.
    So you lose with 1 point.
  • In the third round, your opponent plays Scissors and you choose Scissors too.
    So you make a draw with 6 points.

You’ll end the tournament with 15 points


For this exercise, I’ll simply iterate on every round and compute the score by looking at :

  • My choice
  • The winner of the game



Matt E.

Software engineer at Achiev & Jounco. Passionate about programming and entrepreneurship