A set of C# source generators to build an agent for your Advent of Code solutions — an application that downloads inputs and submits answers.
- Identifies days that have not been solved yet.
- Checks if a day's solution meets the specified examples.
- Downloads input, performs calculations, and submits the answers.
- Informs you when your answer was rejected.
- If the previous answer was given too recently, waits the necessary duration and resubmits.
- Generates NUnit tests for the implemented solutions.
- Caches everything so that does not hurt AoC servers much and you don't get penalties for submitting the same incorrect answers.
- Does not parse the input for you.
- Does not include specialized algorithms (e.g., BFS, LCM, OCR) that are typical for AoC.
-
Create an empty console project and add the Agent package to it
dotnet new console -n aoc dotnet add aoc package mazharenko.AocAgent
-
Remove the default Program.cs file
-
Define a single year class anywhere in the project named like
YearXXXXwith the[GenerateEntryPoint]attribute. Don't forget thepartialkeyword.[GenerateEntryPoint] public partial class Year2022;
-
Define day classes named like
DayXX. Don't forget thepartialkeyword. Provide examples and implementation.partial class Day01 { internal partial class Part1 { private readonly Example example1 = new("input", "expectation"); private readonly Example example2 = new("input", "expectation"); public string Solve(string input) { return "expectation"; } } internal partial class Part2 { ... } }
-
When run for the first time, it requests the
sessioncookie value from https://adventofcode.com/session1.mp4
-
Run the program. If the implementation is correct, you will earn an Advent of Code star.
It works best with
dotnet watch. With it, if any issues with the implementation are detected, it will automatically restart after code changes.demo1.mp4
Note
More info is provided in the docs
aoc-agent-template and aoc-agent-template-multipleyears are prepared repository templates with all required references and 25 day drafts. The latter assumes that the repository will contain solutions for several years.