Today I’ll detail my solution for the third challenge of the Advent of Code 2022.
You can find here my solution for day 1 and day 2.
One of the elves is responsible for loading the rucksacks with supplies for the jungle journey. Unfortunately, he didn’t follow the instructions and some items needed to be rearranged.
Each rucksack has two compartments, and each item’s type is associated with one of those compartments. The elf who loaded the rucksacks made a mistake for exactly one item in each rucksack.
In other words, in each rucksack we have exactly one item who is present in both compartments. That’s where the error is.
In the input, each item is described by a letter and is associated with a priority score. The score is computed from the letter using the following rules :
Part 1
The elves give you the list of items for each rucksack.