Here are my solutions for the Advent of Code event.
This year I gave in to the AI hype and tried to build an AI workflow of solving AoC puzzles. Not to delegate writing code to LLMs, but to automate procesess such as:
- Downloading an input file
- Running an application, feeding the input file to it
- Interpreting arbitrary application output
- Submitting answers
- Updating test cases
Opencode agent equipped with a custom MCP server worked fairly well.
However, using aoc-agent guarantees the fastest submission.
The Superpower extensions received two important updates:
LinesandLines-based parsers now effectively split aTextSpan(withExceptSkipinstead ofThenIgnore), which allows combiningCharacters.AnyCharwith new lines.// line breaks fall into the AnyChar category, but on each line only that line is visible to the parser Character.AnyChar.Map();
- Similarly,
Templateparsers effectively split the interpolated string by literals which prevents the injected parses from messing up with literals.// the ' ' (space) literal is invisible to the first parser Template.Matching<int[], int>($"{Numerics.Integer32.ManyDelimitedBySpaces()} {{{Numerics.Integer32}}}")
I had been missing various features of C#. At the same time, I was wondering how well I could handle situations where I had previously relied heavily on specific features of F#. So, this year, I decided to solve the AoC puzzles in C#. And I would catch myself willing to have type aliases / tail recursion / structural equality / whatever, but generally speaking, it was a more comfortable experience, especially since I did not have to push myself to avoid using an imperative style.
Additionally, I was looking forward to improving the parsing process. I tried out Superpower and managed to achieve a concise syntax for some common patterns found in AoC inputs like lines and blocks. It worked fairly well, though dealing with its backtracking was tricky. I also succeeded to construct a parser from a template with use of custom interpolated string handlers, like the following:
Template.Matching<int, int>($"p={Numerics.IntegerInt32},{Numerics.IntegerInt32};") // TextParser<(int, int)>Some more functions have been added to the aoc-agent, the most significant update is that example inputs and Parse method can now be easily reused across the parts of a single day.
No longer happy with notebooks. Decided to sacrifice visualization at all and focus on a different thing: on optimizing the routine when solving puzzles, namely:
- Go to the site and download the input.
- Feed the input to the program.
- Copy the result to the clipboard.
- Paste it into the browser.
- Doh, wrong.
- Fix, compile, run, copy, paste.
- Doh, "You gave an answer too recently."
- Wait.
- Repeat.
This is how I came up with the idea of aoc-agent — a C# source generator that turns your library with actual algorithms into a self-validating, self-running console application that calculates and submits answers automatically.
Once again, F#. Found Farkle to be much better, still cumbersome and mind-numbing sometimes.
More F# and more visualization in a notebook. Try FParsec to parse input. Try lenses 😱.
Continue playing with F#. Discovered wonderful .NET Interactive notebooks. Invested into the presentation of the results: mermaid, plotly, canvas.
First time taking part in the event. As a C# developer who was reading a lot about F#, wanted to give it a try on "real" tasks. It showed to be quite suitable for many puzzles thanks to immutability and structural comparison out of the box.








































































































































