Tidy.AdventOfCode
1.0.0
See the version list below for details.
dotnet add package Tidy.AdventOfCode --version 1.0.0
NuGet\Install-Package Tidy.AdventOfCode -Version 1.0.0
<PackageReference Include="Tidy.AdventOfCode" Version="1.0.0" />
paket add Tidy.AdventOfCode --version 1.0.0
#r "nuget: Tidy.AdventOfCode, 1.0.0"
// Install Tidy.AdventOfCode as a Cake Addin #addin nuget:?package=Tidy.AdventOfCode&version=1.0.0 // Install Tidy.AdventOfCode as a Cake Tool #tool nuget:?package=Tidy.AdventOfCode&version=1.0.0
Tidy.AdventOfCode
Yo, ho ho!
Tidy.AdventOfCode
is a free, simple runner and framework for creating and posting your solutions for the awesome Advent of Code yearly riddle-fest in (the also awesome) .NET!
What it does
Tidy.AdventOfCode
provides a framework for running your solutions for Advent of Code riddles, and that means there are predefined types (like Day<T>
) that help you organize your code or reduce boilerplate. If you follow the example below, you'll see everything will "just work". You add your solution for the day, start the runner (providing the proper year
, dayNumber
and part
values are still your responsibility, maybe use a Console.ReadLine()
for getting them from the console), and your solution gets automagically calculated for the input that gets pulled (and cached ) from the server. Then, your answer in hand, your solution gets posted to the server, and the result from the server gets rendered on your console!
Prerequisites
You need at least version 5.0 of the .NET SDK installed. Nothing else. Although a code editor or an IDE might be a good idea.
Low maintenance
Create a new Console app:
dotnet new console -f net5.0
Add a little Tidy.AdventOfCode NuGet sprinkle:
dotnet add package Tidy.AdventOfCode
Create a default runner (replace
Program.cs
):using System; using System.IO; using Tidy.AdventOfCode; var dataDirectory = Directory.CreateDirectory(Path.Combine(Environment.GetEnvironmentVariable("APPDATA")!, "YuGabe.AdventOfCode")).FullName; // You can use whichever directory you like, AppData is easy as it's not as protected. Also, obviously, this won't work on *nix. var runner = Runner.CreateDefault(dataDirectory); await runner.ExecuteAsync( year: DateTime.Today.Year, dayNumber: DateTime.Today.Day, part: 1);
Log in to the Advent of Code site and copy the value of the
session
cookie:Save the value in a file at the above directory named
cookie.txt
:Create your solution for the day:
using System.Linq; using Tidy.AdventOfCode; namespace YourName.AdventOfCode.Year2020 { class Day1 : Day<string>.Raw { public override object ExecutePart1() => Input.Count(c => c is '(' or ')'); } }
Watch, as magic happens!
dotnet run
Things to note
The biggest issue you might run into is when you submit answers less, than a minute apart each other. In this case, for your consequent calls, the warning message will be cached for your answer (whether it was the right or wrong one). In this case you might need to manually delete the corresponding cache entries (or the cache entirely, if you like).
The public API is fully documented (it is of good quality too, if I may say so myself), so you can start hacking away as much as you like and find new things to do magic with.
The API is designed in a way to be fully expandable (by inheriting) or to be as easy as possible.
For pros, you can switch out any of the underlying services that are registered in the service provider. IDay
instances are instantiated using DI.
The Advent of Code server isn't designed to be used this way. Please, be mindful and don't use any of your code for malicious purposes, such as DDOSing the server. You are identified by your IP address (and specifically, by the session cookie), so consider yourself informed.
If you have some questions, feel free to browse the source or open an issue. I don't plan to extend the current solution very much (unless public demand shows to or I happen to get another), so if you wish to modify anything in the framework, feel free to open a pull request or fork the repo.
The cached inputs, answers and responses are all in a human-readable and machine-readable format, so feel free to abuse the cache folder to your liking.
Pro tips
There are some fluent generics used to construct differently parsed input-handling Day<T>
objects, such as Day<T>.ForMany<TParser>
. Yes, that is a type! This can reduce boilerplate parsing the input values quite significantly.
You can create your own Runner, if you would only like a part of the functionality Tidy.AdventOfCode
provides. There is also a handy extension method for registering with any IServiceCollection
, like services.AddTidyAdventOfCode(...)
.
Keep on hackin'! Click the ⭐ on GitHub!
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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. |
-
net5.0
- HtmlAgilityPack (>= 1.11.28)
- Microsoft.Extensions.DependencyInjection (>= 5.0.0)
- Microsoft.Extensions.Logging.Console (>= 5.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.