AOC 2022 — Day 3

Matt E.
6 min readJan 17, 2023

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.

https://adventofcode.com/2022/day/3

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.

Visual representation of the error

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 :

Rules to compute priority score

Part 1

The elves give you the list of items for each rucksack.

--

--

Matt E.
Matt E.

Written by Matt E.

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

No responses yet