*Descriptions of the solutions for this edition are mostly AI generated due to lack of time.
Solver implementation
The implementation of the Kotlin solver consists of two main components, compiled ahead of time into a single executable jar rather than interpreted at runtime.
Solver Class
Abstract base class that defines the structure for solving the challenges, mirroring the Python edition’s Solver interface. Abstract methods:
parseInput(): Parses the raw input data into a structured form.solveFirstPart(parsed): Solves the first part of the challenge.solveSecondPart(parsed): Solves the second part of the challenge.
Each day’s solution module defines a Solution class extending Solver, implementing the parsing and solving logic for that day’s challenge. The base class also handles timing and formatted output for each part via its run() method.
Compilation and Reflective Module Loading
Unlike the Python edition, Kotlin has no runtime equivalent of importlib — solution classes must be compiled ahead of time. The build is managed with Gradle, using the Shadow plugin to package the base solver and every day’s solution into a single fat jar (aoc-solver.jar).
- Each day’s
Solutionclass lives in a package following the conventioneditions.y{year}.day{day}, e.g.editions.y2025.day1. - At startup, the
SolverMainentrypoint reads--yearand--dayarguments and uses Java’s reflection API (Class.forName) to locate and instantiate the correspondingeditions.y{year}.day{day}.Solutionclass at runtime — functionally equivalent to the Python solver’s dynamicimportlibloading, but resolved against classes already present in the compiled jar rather than loaded from a file path. - Puzzle input is streamed to the process via stdin and read in full with
readText()before being passed to theSolutionconstructor. - Once instantiated,
run()executes the challenge, handling Part 1, Part 2, or both depending on the provided arguments — identical behavior to the PythonSolver.run()method.
Build and Deployment
The web server runs in a Docker container built in two stages: the first compiles the Kotlin sources with Gradle into the fat jar, and the second is a slim Python + JRE runtime image that invokes the jar as a subprocess alongside the existing language runners, using the same --year/--day/--part interface as every other supported language.