My solutions for Advent of Code 2021.
(TODO: add final picture of AoC calendar)
(TODO: impressions about this year's event)
🚀 TLDR: an online event where a two-part programming puzzle is released each day from Dec 1st to 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
My solutions for the puzzles are available in the folder 📁 my_solutions and are organized into subfolders for each day of the event.
In this folder's root, the following files can be found:
puzzle_solver.py
- main framework developed to streamline coding.solve_puzzles.py
- script for running the puzzle solving codes.Makefile
- used for starting the execution of the above script.
Inside each subfolder, the following files can be found:
input_test.txt
- text file containing input from tests given in the puzzle.input.txt
- text file containing my personal input for the puzzle.main.py
- Python code for solving the puzzle.
Solve puzzle for a certain day:
make day=01
Solve puzzle for a certain day and part:
make day=08 part=1
make day=08 part=2
Solve puzzle for testing input:
make test day=12
make test day=12 part=1
Create a new day folder from template:
make new day=02
DAY | PUZZLE TITLE | PUZZLE SUMMARY |
---|---|---|
📁 01 | Sonar Sweep | 📃 Input: the sonar sweep report - a list of measurements of the sea floor depth (a list of integers). ⭐ Part One: count the number of times a depth measurement increases from the previous measurement. ⭐ Part Two: count the number of times the sum of three-measurement windows increases from the previous sum. |
📁 02 | Dive! | 📃 Input: a list of commands - a tuple of a direction and an integer number. ⭐ Part One: follow the planned course (list of commands) to calculate the final horizontal position and depth; multiply them. ⭐ Part Two: same as before, but with a new interpretation of the commands. |
📁 03 | Binary Diagnostic | 📃 Input: the submarine's diagnostic report - a list of binary numbers. ⭐ Part One: use the binary numbers to calculate the gamma rate and epsilon rate, then multiply them together to find the power consumption of the submarine. ⭐ Part Two: use the binary numbers to calculate the oxygen generator rating and CO2 scrubber rating, then multiply them together to find the life support rating of the submarine. |
📁 04 | Giant Squid | 📃 Input: a random order in which to draw numbers and a random set of bingo boards. ⭐ Part One: figure out which board will win first, then calculate the final score for that board. ⭐ Part Two: figure out which board will win last, then calculate the final score for that board. |
📁 05 | Hydrothermal Venture | 📃 Input: a list of nearby lines of vents - a list of 2D coordinate pairs. ⭐ Part One: only consider horizontal and vertical lines and find how many points at least two lines overlap. ⭐ Part Two: same as before, but including diagonals. |
📁 06 | Lanternfish | 📃 Input: a list of the ages of several hundred nearby lanternfish - a comma separated list of integers. ⭐ Part One: simulate lanternfish spawning to find how many lanternfish would there be after 80 days. ⭐ Part Two: same as before, but for 256 days. |
📁 07 | The Treachery of Whales | 📃 Input: a list of the horizontal position of each crab - a comma separated list of integers. ⭐ Part One: find the least fuel possible used to align the crabs position. ⭐ Part Two: same as before, but with a new fuel cost rate. |
📁 08 | Seven Segment Search | 📃 Input: a list of signal patterns and output values - a list of lowercase strings. ⭐ Part One: find how many times do digits 1, 4, 7, or 8 appear. ⭐ Part Two: decode the output values and add them all up. |
📁 09 | Smoke Basin | 📃 Input: a heightmap of the floor of the nearby caves. ⭐ Part One: find the sum of the risk levels of all low points on the heightmap. ⭐ Part Two: find the product of the sizes of the three largest basins. |
📁 10 | Syntax Scoring | 📃 Input: the navigation subsystem - a list of brackets and parenthesis. ⭐ Part One: find the total syntax error score of the navigation subsystem. ⭐ Part Two: find the middle score of the incomplete lines in the navigation subsystem. |
📁 11 | Dumbo Octopus | 📃 Input: a grid of octopus' energy levels - a grid of single digit integers. ⭐ Part One: find the total flashes after simulating 100 steps. ⭐ Part Two: find the first step during which all octopuses flash. |
📁 12 | Passage Pathing | 📃 Input: a map of the remaining caves - a list of connections between pairs of caves. ⭐ Part One: find how many paths through this cave system are there that visit small caves at most once. ⭐ Part Two: same as before, but now allowing to visit a single small cave twice. |
📁 13 | Transparent Origami | 📃 Input: a list of coordinates of the dots marked in the transparent paper and a list of folding instructions. ⭐ Part One: find how many dots are visible after completing just the first fold instruction on the transparent paper. ⭐ Part Two: finish folding the transparent paper according to the instructions to find the eight capital letters code to activate the infrared thermal imaging camera system. |
📁 14 | Extended Polymerization | 📃 Input: a polymer template and a list of pair insertion rules. ⭐ Part One: apply 10 steps of pair insertion to the polymer template and find the difference between counts of the most and least common elements in the result. ⭐ Part Two: same as before, but for 40 steps. |
📁 15 | Chiton | 📃 Input: a map of risk level - a grid if non spaced one digit integers. ⭐ Part One: find the path from the top left to the bottom right with the lowest total risk. ⭐ Part Two: same as before, but with a five-times-as-large version of the risk level map. |