Pillsgood.AdventOfCode
3.0.2-alpha
See the version list below for details.
dotnet add package Pillsgood.AdventOfCode --version 3.0.2-alpha
NuGet\Install-Package Pillsgood.AdventOfCode -Version 3.0.2-alpha
<PackageReference Include="Pillsgood.AdventOfCode" Version="3.0.2-alpha" />
<PackageVersion Include="Pillsgood.AdventOfCode" Version="3.0.2-alpha" />
<PackageReference Include="Pillsgood.AdventOfCode" />
paket add Pillsgood.AdventOfCode --version 3.0.2-alpha
#r "nuget: Pillsgood.AdventOfCode, 3.0.2-alpha"
#:package Pillsgood.AdventOfCode@3.0.2-alpha
#addin nuget:?package=Pillsgood.AdventOfCode&version=3.0.2-alpha&prerelease
#tool nuget:?package=Pillsgood.AdventOfCode&version=3.0.2-alpha&prerelease
Pillsgood.AdventOfCode
Helpers for solving Advent of Code puzzles from unit tests. It handles:
- Fetching your puzzle input
- Converting input into convenient types
- Submitting/validating your answers
Built for use with NUnit but probably works with other test frameworks too.
Quick start (NUnit)
Add NuGet package
Pillsgood.AdventOfCodeto project.- Optionally, add
Pillsgood.AdventOfCode.Loginfor interactive login (currently win-x64 only).
- Optionally, add
Add a one-time startup/teardown to your test assembly to initialize the library.
[SetUpFixture] public sealed class AdventSetup { private IDisposable? _app; [OneTimeSetUp] public void Start() => _app = Aoc.Start(cfg => { cfg.WithSession("your_session_cookie_here"); // or cfg.WithLogin(); }); [OneTimeTearDown] public void Stop() => _app?.Dispose(); }Create test classes that inherit from
AocFixture. UseInputto read puzzle input andAnswerto submit/validate.namespace Y2024; public class Day01Tests : AocFixture { [Test] public void Part1() { var numbers = Input.Get<int[]>(); Answer.Submit(numbers.Sum()); } }
Naming conventions
The library detects which puzzle you're solving by inspecting the call stack:
- Year: any
20xxin the test class' full name (namespace or type name) - Day:
DayN/DayNNin the test class' full name - Part:
Part1orPart2in the test method name
If you prefer not to inherit from AocFixture, mark your own base class with [AocFixture] and resolve
IPuzzleInputService / IAnswerAssertion from Locator.
Reading input
Input.Get<T>() converts the input to T: string, numbers, anything IParsable, and arrays, lists, sets or other
collections of those (one element per line). Extra arguments are passed to the conversions that use them.
var text = Input.Get<string>();
var lines = Input.Get<List<string>>();
var set = Input.Get<HashSet<long>>();
var binary = Input.Get<int[]>(NumberStyles.BinaryNumber);
var words = Input.Get<string[]>(StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
Lines are not trimmed unless you pass StringSplitOptions.
Custom types can be added with a converter. It's combined with the built-in conversions, so this also enables Point[],
HashSet<Point> and so on:
cfg.AddInputConverter<string, Point>(Point.Parse);
For more control, implement IInputConverter<TIn, TOut> (generic converters are supported) and register it the same way.
Submitting/validating answers
Answer.Submit(12345);
await Answer.SubmitAsync("ABCDEF");
The answer is submitted if it isn't known yet. Once accepted, it's cached and later runs assert against it instead of re-submitting.
Configuration
WithSession("<session_cookie>"): thesessioncookie fromadventofcode.comWithLogin()(fromPillsgood.AdventOfCode.Login): login window that acquires and caches the sessionWithSessionProvider(...): customISessionProviderWithCachePath(".aoc-cache.db"): cache file for inputs, answers and the session (defaults tostore.db)SetEntryAssembly(...): only needed if your tests run from a different assembly than the one callingAoc.StartAddInputConverter(...): custom input conversions
An invalid/expired session is cleared and requested again.
License
See LICENSE.md.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- AwesomeAssertions (>= 9.3.0)
- Microsoft.Extensions.Caching.Hybrid (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.0)
- NeoSmart.Caching.Sqlite (>= 9.0.1)
- SoftCircuits.HtmlMonkey (>= 3.1.0)
- SourceGear.sqlite3 (>= 3.50.4.5)
- SQLitePCLRaw.config.e_sqlite3 (>= 3.0.2)
- SQLitePCLRaw.provider.e_sqlite3 (>= 3.0.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Pillsgood.AdventOfCode:
| Package | Downloads |
|---|---|
|
Pillsgood.AdventOfCode.Login
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.12-alpha | 0 | 12/5/2026 |
| 3.0.5-alpha | 0 | 12/5/2026 |
| 3.0.2-alpha | 0 | 12/5/2026 |
| 2.2.11-alpha | 57 | 12/2/2026 |
| 2.2.10-alpha | 63 | 12/2/2026 |
| 2.2.7-alpha | 128 | 9/2/2026 |
| 2.2.6-alpha | 132 | 9/1/2026 |
| 2.2.5-alpha | 128 | 9/1/2026 |
| 2.2.3-alpha | 129 | 8/31/2026 |
| 2.2.1-alpha | 126 | 8/31/2026 |
| 2.1.15-alpha | 128 | 8/31/2026 |
| 2.1.13 | 357 | 12/4/2025 |
| 2.1.12-alpha | 268 | 12/4/2025 |
| 2.1.11-alpha | 276 | 12/4/2025 |
| 2.1.7-alpha | 282 | 12/4/2025 |
| 2.0.23 | 316 | 12/4/2025 |
| 2.0.22 | 782 | 12/2/2025 |
| 2.0.21 | 774 | 12/2/2025 |
| 2.0.20 | 773 | 12/2/2025 |
| 2.0.19 | 793 | 12/2/2025 |