Advent of code is an annual coding competition where you need to solve two problems every day.
Here I share my original solutions for all problems (2022 and 2023). Not all of them are optimal in terms of complexity but all of them solve the stated problems in a reasonable time. I tried to post the actual solutions that I came ups with during the contest to show how exactly I solved the problems back then given the time pressure. But I still do some code refactoring and small optimization before posting to make it more readable.
Years 2022 and 2023 are solved using Python. Every N.py
file contains at least 3 functions:
prepare_data
- reads the input file and prepares data to be used in the solutionsolve1
- solution of the first problemsolve2
- solution of the second problem
You can get the result of algorithm by running: solve1(**prepare_data("input.txt"))
I also started solving old problems from 2015 using C++ from time to time. You just need to compile N.cpp
code and run it with input.txt
in the same directory to get the result.
All algorithms expect valid inputs to work correctly, e.g. if in the original problem description it is stated that the question has only one answer there should be only one valid answer.