Tidy.AdventOfCode 1.0.0

.NET 5.0
There is a newer version of this package available.
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
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Tidy.AdventOfCode" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Tidy.AdventOfCode --version 1.0.0
#r "nuget: Tidy.AdventOfCode, 1.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// 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

Advent of Code logo


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!


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

  1. Create a new Console app:

    dotnet new console -f net5.0

  2. Add a little Tidy.AdventOfCode NuGet sprinkle:

    dotnet add package Tidy.AdventOfCode

  3. 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);
  4. Log in to the Advent of Code site and copy the value of the session cookie:

    Copy your the value from the cookie named 'session'

  5. Save the value in a file at the above directory named cookie.txt:

    Save the value of your 'session' cookie in a file named  'cookie.txt'

  6. 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 ')');
  7. 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
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

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.0.4 48 12/5/2022
2.0.3 68 12/1/2022
2.0.2 308 12/10/2020
2.0.1 346 12/6/2020
2.0.0 282 12/4/2020
1.2.1 259 12/4/2020
1.2.0 283 12/3/2020
1.1.0 288 12/3/2020
1.0.0 272 12/2/2020