My solutions for Advent of Code 2022.
About ยท What is Advent of Code? ยท Contents ยท Usage ยท Table of puzzles
(TODO: add final picture of AoC calendar)
(TODO: write)
๐ TLDR: an online event where a two-part programming puzzle is released each day from Dec 1st to the 25th.
Advent of Code is an online event created by Eric Wastl. In his words:
Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like. People use them as a speed contest, interview prep, company training, university coursework, practice problems, or to challenge each other.
Source: https://adventofcode.com/about
โ๏ธ Important: This repo was created from the template advent_of_code-template, please refer to its documentation for more information.
My solutions for the puzzles are available in the folder ๐ my_solutions and are organized into subfolders for each day of the event.
Inside each subfolder, the following files can be found:
input_test.txt
- contains input from tests given in the puzzle.input.txt
- contains my personal input for the puzzle.main.py
- Python code for solving the puzzle.README.md
- contains a tldr of the puzzle.solutions.txt
- contains the solutions to my inputs for the puzzle.
Python 3.10
termcolor
make
(for runningMakefile
)
$ make d=1
$ make d=8 p=1
$ make d=8 p=2
$ make test d=12
$ make test d=12 p=1
DAY | PUZZLE TITLE | PUZZLE SUMMARY |
---|---|---|
๐ 01 | Calorie Counting | ๐ Input: a list of calories (integers) grouped by elf. โญ Part One: find the most total calories an elf is carrying. โญ Part Two: find the sum of calories of the 3 elves that are carrying the most total calories. |
๐ 02 | Rock Paper Scissors | ๐ Input: an encrypted strategy guide. โญ Part One: find the total score after following the strategy guide. โญ Part Two: find the total score after following the strategy guide, with a new interpretation of the guide. |
๐ 03 | Rucksack Reorganization | ๐ Input: a list of all of the items currently in each rucksack (a list of strings). โญ Part One: find the sum of the priority of the common item type. โญ Part Two: find the sum of the priority of the badges (common item type for each group of 3 rucksacks). |
๐ 04 | Camp Cleanup | ๐ Input: a list of the section assignments for each pair of elf (a list of range pairs). โญ Part One: find how many pairs in which one range fully contains the other. โญ Part Two: find how many pairs in which the ranges overlap. |
๐ 05 | Supply Stacks | ๐ Input: a drawing of the starting stacks of crates and the rearrangement procedure (moves). โญ Part One: find what crate ends up on top of each stack after the rearrangement procedure completes. โญ Part Two: same as before, but with a different rearrangement procedure. |
๐ 06 | Tuning Trouble | ๐ Input: a datastream buffer (a string of lowercase alphabetic characters). โญ Part One: find how many characters need to be processed before the first start-of-packet marker is detected. โญ Part Two: find how many characters need to be processed before the first start-of-message marker is detected. |
๐ 07 | No Space Left On Device | ๐ Input: the resulting terminal output of browsing around the device's filesystem. โญ Part One: find the sum of all of the directories with a total size of at most 100000. โญ Part Two: find the smallest directory that, if deleted, would free up enough space on the filesystem to run the update. |
๐ 08 | Treetop Tree House | ๐ Input: a map with the height of each tree (a grid of single digit integers). โญ Part One: find how many trees are visible from outside the grid. โญ Part Two: find the highest scenic score possible for any tree. |
๐ 09 | Rope Bridge | ๐ Input: a list of moves. โญ Part One: simulate the series of motions to find how many positions the rope's tail visited at least once. โญ Part Two: same as before, but now the rope has ten knots. |
๐ 10 | Cathode-Ray Tube | ๐ Input: a list of CPU instructions. โญ Part One: find the sum of the six signal strengths. โญ Part Two: find the eight capital letters that appear after rendering the image given by the program. |
๐ 11 | Monkey in the Middle | ๐ Input: notes on the items each monkey currently has, how worried you are about those items, and how the monkey makes decisions based on your worry level. โญ Part One: count how many items the monkeys inspect over 20 rounds, then calculate the level of monkey business. โญ Part Two: same as before, but without reducing the worry levels after each inspection and for 10.000 rounds. |
๐ 12 | Hill Climbing Algorithm | ๐ Input: a heightmap of the surrounding area. โญ Part One: find the fewest steps required to move from the current positions to the highest location. โญ Part Two: find the fewest steps required to move starting from any square with the lowest elevation to the highest location. |
๐ 13 | Distress Signal | ๐ Input: the list of received packets. โญ Part One: find the sum of the indices of pairs of packets that are in the right order. โญ Part Two: organize all of the packets into the correct order to find the decoder key for the distress signal. |
๐ 14 | Regolith Reservoir | ๐ Input: the scan of a two-dimensional vertical slice of the cave. โญ Part One: simulate the falling sand to find how many units of sand come to rest before sand starts flowing into the abyss below. โญ Part Two: simulate the falling sand until the source of the sand becomes blocked, then find how many units of sand come to rest. |
๐ 15 | Beacon Exclusion Zone | ๐ Input: a list of sensor positions and closest beacons. โญ Part One: in the row where y=2000000, find how many positions cannot contain a beacon. โญ Part Two: find the only possible position for the distress beacon, then calculate its tuning frequency. |
๐ 16 | Proboscidea Volcanium | ๐ Input: a report of each valve's flow rate if it were opened (in pressure per minute) and the tunnels that connect the valves. โญ Part One: find the most pressure you can release form the valves. โญ Part Two: with you and an elephant working together for 26 minutes, find the most pressure that could be released. |
๐ 17 | Pyroclastic Flow | ๐ Input: a list of jets of hot gas. โญ Part One: find how many units tall will the tower of rocks be after 2022 rocks have stopped falling. โญ Part Two: find how tall will the tower be after 1000000000000 rocks have stopped. |
๐ 18 | Boiling Boulders | ๐ Input: a quick scan of a droplet (a list of 3D coordinates). โญ Part One: find the surface area of the scanned lava droplet. โญ Part Two: find the exterior surface area of the scanned lava droplet. |
๐ 19 | Not Enough Minerals | ๐ Input: a list of blueprints. โญ Part One: determine the quality level of each blueprint using the largest number of geodes it could produce in 24 minutes, then add up the quality level of all of the blueprints in your list. โญ Part Two: determine the largest number of geodes that could be opened using each of the first three blueprints, then multiply these numbers together. |
๐ 20 | Grove Positioning System | ๐ Input: a file that contains the grove's coordinates (a list of integers). โญ Part One: mix your encrypted file exactly once, then find the sum of the three numbers that form the grove coordinates. โญ Part Two: apply the decryption key and mix your encrypted file ten times, then find the sum of the three numbers that form the grove coordinates. |
๐ 21 | Monkey Math | ๐ Input: a list of monkey math. โญ Part One: find what number will the monkey named root yell. โญ Part Two: find what number do you yell to pass root's equality test. |
๐ 22 | Monkey Map | ๐ Input: a map of the board (a 2D grid representation of a cube) and the path you must follow (an alphanumeric string). โญ Part One: follow the path given in the monkeys' notes to find the final password. โญ Part Two: fold the map into a cube, then follow the path given in the monkeys' notes to find the final password. |
๐ 23 | Unstable Diffusion | ๐ Input: a scan of the grove. โญ Part One: simulate the Elves' process and find the smallest rectangle that contains the Elves after 10 rounds, then find how many empty ground tiles that rectangle contains. โญ Part Two: figure out where the Elves need to go, then find the number of the first round where no Elf moves. |
๐ 24 | Blizzard Basin | ๐ Input: a map of the valley and the blizzards. โญ Part One: find the fewest number of minutes required to avoid the blizzards and reach the goal. โญ Part Two: find the fewest number of minutes required to reach the goal, go back to the start, then reach the goal again. |
๐ 25 | Full of Hot Air | ๐ Input: a list of all of the fuel requirements. โญ Part One: find the SNAFU number needed to supply to Bob's console. |