AdventOfCode.Framework
1.2.1
See the version list below for details.
dotnet add package AdventOfCode.Framework --version 1.2.1
NuGet\Install-Package AdventOfCode.Framework -Version 1.2.1
<PackageReference Include="AdventOfCode.Framework" Version="1.2.1" />
<PackageVersion Include="AdventOfCode.Framework" Version="1.2.1" />
<PackageReference Include="AdventOfCode.Framework" />
paket add AdventOfCode.Framework --version 1.2.1
#r "nuget: AdventOfCode.Framework, 1.2.1"
#:package AdventOfCode.Framework@1.2.1
#addin nuget:?package=AdventOfCode.Framework&version=1.2.1
#tool nuget:?package=AdventOfCode.Framework&version=1.2.1
Advent of Code Framework
Simple framework to bootstrap Advent of Code solutions.
Modes
The framework supports two run modes:
Solve Mode
Runs solutions and outputs the result from the problems.
Benchmark Mode [In Development]
Benchmarks solution problems.
Setting Up Solutions
A solution needs to satisfy four constrains: inheriting from Solution, having a constructor which takes in a single parameter of type Input, having a single Solution attribute, and having at least one SolutionInput attribute.
A solution should then look something like this:
using AdventOfCode.Framework;
[Solution(1)]
[SolutionInput("Input.txt")]
public class MySolution : Solution
{
public MySolution(Input input) : base(input)
{
}
protected override string? Problem1()
{
return null;
}
protected override string? Problem2()
{
return null;
}
}
The solutions to the problems should be returned from Problem1 and Problem2 as strings.
Running
The entry point to the framework is the SolutionRunner.
SolutionRunner runner = new();
You can then run the solution runner directly in one of the two modes and for a specific combination of days/problems.
// Solve mode
runner.Solve(1, Problem.Problem2);
runner.Solve(1);
runner.SolveLatest();
runner.SolveAll();
// Benchmark mode
runner.Benchmark(1, Problem.Problem2);
runner.Benchmark(1);
runner.BenchmarkAll();
There is also an option intended to work with the command line:
runner.Run(args);
The arguments passed to Run can define the two modes as follows:
run <day> [problem]
benchmark <day> <problem>
for example:
runner.Run(new string[] { "run", "1", "1" });
Note that SolveLatest is not supported with run arguments.
Solution Options
Solution Attribute
The solution attribute takes in the day that the solution corresponds to, and optionally whether the solution is enabled.
[Solution(1, Enabled = true)]
Solution Input Attribute
The solution input attribute takes in a path to an input file to run the solution for. This is by default resolved from the base directory of the project but this can be changed via the SolutionRunner options. Optional properties can be set to enable/disable the input, specify that the input is only relevant to a single problem and enable benchmarking.
[SolutionInput("Input.txt", Enabled = true, Benchmark = true, Problem = Problem.All)
*Note that in benchmark mode, only inputs marked with Benchmark = true will be considered. This is false by default.
Notes
Input
Input is read by the framework and can be accessed in the solution via the Input property (or directly in the constructor).
Process
Each problem run instantiates a new solution, so state can't be shared between runs. Benchmarking includes the runtime of the constructor as well as the specific problem, however it doesn't include reading input files.
Disabling Problems
A problem that returns null is not considered as having failed and therefore will not contribute to the benchmarks, or stop the current run.
Pitfalls
Input file paths should be specified relative to the output directory (or usually relative to the project root). For this to work the files need to be setup to copy over when building (https://social.technet.microsoft.com/wiki/contents/articles/53248.visual-studio-copying-files-to-debug-or-release-folder.aspx).
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 2.6.2 | 235 | 12/6/2025 | |
| 2.6.1 | 227 | 12/6/2025 | |
| 2.6.0 | 229 | 12/6/2025 | |
| 2.5.2 | 206 | 12/5/2025 | |
| 2.5.1 | 204 | 12/5/2025 | |
| 2.5.0 | 219 | 12/3/2025 | |
| 2.4.1 | 439 | 11/30/2025 | |
| 2.4.0 | 424 | 11/30/2025 | |
| 2.3.0 | 755 | 11/30/2025 | |
| 2.2.0 | 694 | 11/30/2025 | |
| 2.1.0 | 689 | 11/30/2025 | |
| 2.0.0 | 765 | 11/30/2025 | |
| 1.3.8 | 528 | 12/14/2022 | |
| 1.3.2 | 439 | 12/13/2022 | |
| 1.3.0 | 652 | 12/11/2022 | |
| 1.2.1 | 463 | 12/8/2022 | |
| 1.1.2 | 472 | 12/3/2022 | |
| 1.1.1 | 448 | 12/3/2022 | |
| 1.1.0 | 451 | 12/3/2022 | |
| 1.0.0 | 447 | 12/2/2022 |