This repository provides a framework and helper tools to streamline the process of solving Advent of Code challenges. It includes utilities for building and running Go plugins, managing input files, and running tests.
internal/processor.go
: Contains thePluginProcessor
struct and methods for building plugins, calling functions within those plugins, running tests, and getting input data.internal/input.go
: Contains theArgs
struct and functions for processing command-line arguments and determining file paths.runner.go
: The main entry point that ties everything together by processing arguments, building the plugin, getting input, running tests, and calling the solution function.- It is expected to set up a folder structure following the pattern:
/year/day/partnumber.go
. For example, for the first part of the first day's challenge in 2024, the file should be located at/2024/day1/part1.go
. - It is expected to add test files for each day. As a minimal it is adviced to add a test case for each part of a day based on the sample input and output provided by
Advent of Code
.
- Process Arguments: The tool processes command-line arguments to determine the year, day, part, and input type (sample or input) of the challenge.
- Build Plugin: It builds the Go plugin for the specified challenge part.
- Get Input: Reads the input file for the challenge.
- Run Tests: Executes tests for the specified challenge.
- Call Function: Calls the solution function from the built plugin and prints the output.
The tool can be given 3 arguments:
-day string
Day of the challenge. 0 to run all days. (default "0")
-part string
Part of the challenge. 0 to run all parts (default "0")
-year string
Year of the challenge (default "2024")
Where days and parts are optional:
- If no days are provided, all days will be run.
- If a day is provided but no parts, all parts of that day will be run.
To run the tool, use the following command:
go run runner.go -year=2024 -day=1 -part=1
This command will:
- Process the arguments for year 2024, day 1, part 1, and use the sample input.
- Build the plugin for the specified challenge.
- Read the sample input file.
- Run tests for the specified challenge.
- Call the solution function and print the output.
Feel free to open issues or submit pull requests if you have any improvements or bug fixes.
This project is licensed under the MIT License.