Day 1
Day 2
Day 3
Day 4
Day 5
Day 6
Day 7
Day 8
Day 9
Day 10
Day 11
Day 12
Day 13
Day 14
Day 15
Day 16
Day 17
Day 18
Day 19
Day 20
Day 21
Day 22
Day 23
Day 24
Day 25
*Descriptions of the solutions for this edition are mostly AI generated due to lack of time.
Solver implementation
The implementation of the Python solver consists of two main components.
Solver Class
Base class that defines the structure for solving the challenges. Abstract methods:
parse_input()
: A method to parse the input data.solve_first_part(parsed_input)
: A method to solve the first part of the challenge.solve_second_part(parsed_input)
: A method to solve the second part of the challenge.
Actual solution modules define this class by implementing the abstract methods for input parsing and solving the challenge.
Dynamic Module Loading
When the solver is executed by the web server runner, the main method uses the Python library importlib
to dynamically
import the solution module for the specified year and day:
- The module is loaded from a specific path (
../editions/{year}/day{day}/solution.py
) corresponding to the selected AoC edition year and day. - The script expects each solution module to define a class named
Solution
, which implements the logic for solving the challenge. - The solution module is dynamically imported using
importlib.util
, and once imported, the script creates an instance of theSolution
class, passing the input data to it. - After the solution module is loaded, the
run()
method of theSolver
class (or its subclassSolution
) is called to execute the challenge solution, handling parts 1 and 2, or both, based on the provided arguments.