r/adventofcode • • 1h ago

Other advent-mode: a small Emacs minor mode for AoC (fetch inputs, submit answers, without leaving Emacs)

4 Upvotes

Hi all,

AoC starts in a few days, so here's a thing I've been using myself: advent-mode, a small Emacs minor mode for the usual AoC chores. I've updated it a bit, and tried using on older puzzles, but additional testing would be great.

In short, you point it at your solutions repo (laid out as year2026/day03/ and so on, and the format is configurable).

Once that's set, it works out the year and day from whatever buffer you're in, so most commands need no prompting. It can:

  • Fetch your puzzle input and open it. It only downloads the first time, so it doesn't hit the server again.
  • Submit an answer for part 1 or 2. It takes the number at point or the active region as the default, and shows you the site's reply.
  • Open the puzzle page in eww.
  • Create a new day directory and copy in your template files.
  • Jump to any day you've already solved.
  • Show year, day and whether you're logged in (✓/✗) in the mode line.

Repo: https://github.com/vkazanov/advent-mode

My own solutions, which show the layout it expects: https://github.com/vkazanov/advent-of-code

Bug reports and "nice-if-s..." suggestions are very welcome (before December, obviously!) .

Good luck to us all this year!


r/adventofcode • • 11h ago

Other My user stylesheet for AOC: "Alter Old CSS"

Post image
16 Upvotes

I appreciate the style of the Advent of Code website. But it's hard to parse quickly, especially in the context of competitive programming. So back in 2025, I created a "user stylesheet" to improve the reading experience while still keeping the general feel of the design. I'm posting it here before the 2026 event, in hopes that it can help other people who feel the same way.

"Alter Old CSS" userstyle: https://userstyles.world/style/25353

To apply this stylesheet, you can install the Stylus browser extension, then go to the stylesheet's userstyles.world page (linked above) and click "Install". It will apply various styles meant to make the reading experience more pleasant, including:

  • Body text in a sans-serif font
  • More responsive design
  • Full-width code blocks (for easier triple-click selection)
  • Hover-text Easter eggs made clearer (NOTE: I also reveal them before all stars are collected, but in white instead of yellow)
  • Clearly delineated sponsor section
  • And more!

If you install this user stylesheet, let me know what you think of it!


r/adventofcode • • 15h ago

Other December Challenges this year

29 Upvotes

Tis the season!

Saw the post on Advent of code and wanted to mention all the other month-long challenges. Was wondering if there are other such challenges, happening annually, that I can look forward to.

  1. Advent of Code
  2. Advent of cyber - TryHackMe
  3. KringleCon

r/adventofcode • • 11h ago

Repo Made a Rust crate for running AoC solutions

3 Upvotes

I’ve been doing Advent of Code for a while, and last year (I forgot to make a post...) I decided to make a little Rust crate to help run my solutions more easily. It’s called aoc-star.

You just add a#[star(day = X, part = X)] attribute to your functions, and it lets you run them from the command line. It can also fetch inputs and submit answers if you set it up with your session cookie.

I've found that it removes a bit of the tedious part of the challenge, hope that it can be useful to some. There is more info on the README.


r/adventofcode • • 19h ago

Visualization [2025 Day 12] [C++] Generic 'solver' of polyomino problems

Post image
10 Upvotes

I made an Interactive solver with custom underlying algorithm for the 'polyomino packing problem' that chews through problems like the above in milliseconds*.

*Note: It's not an 'actual' solver. The problem is still NP-hard. It does not find 'the best' solution nor does it verify that such a solution even exists. What it does do is it computes some 'pretty good' solutions by way of localized 'next step' decisions using various heuristics (somewhat similar to how a human might approach this).

In AoC 2025 day 12 this is good enough ... as I imagine it might be in many practical applications.

Repo: https://github.com/InCom-0/BoxPacker_showcase


r/adventofcode • • 1d ago

Past Event Solutions [2021 Day 19] Finally solved beacons after five years :’)

33 Upvotes

I restarted this for probably the fifth time (but maybe third serious time) last night and stayed up until 4:30AM working on it, drawing lots of pictures. I am not a better programmer at 3:00AM and this is probably the first/most hand written code I’ve done since spring. I was a little worried I’d forget everything I was doing if I went to bed but I woke up three hours later and found the last bug. 🥹 part 2 was really easy except I printed the most recent distance instead of the longest distance and also tried to find the furthest apart beacons instead of scanners. That was easily fixed by reading/trying the sample.

Here is my code


r/adventofcode • • 1d ago

Visualization What animation packages do you use?

7 Upvotes

I've done Advent of Code for the past few years and I'd like to try animating my solutions this time round. I've seen people over the years use a variety of animation software / packages to do their visualization, I'm curious for any specific reccs.

I usually use Python to code up my solutions and was considering learning Manim (the community version) or the base Matplotlib. I've also seen several people using TypeScript/JavaScript to animate. Open to any suggestions!


r/adventofcode • • 1d ago

Repo [2024 Day 16 & 18] [2025 Day 4 & 10] [Kotlin] After 3 years of AoC I collected my helpers into a library

2 Upvotes

This December will be my 4th Advent of Code. I solve it in Kotlin, and before AoC I took part in ICPC. For 3 years I wrote the same code again and again. Every grid began with a table of 4 offsets and a bounds check, and every maze began with a queue and a visited array.

Last year, before AoC 2025, I published the first part of my helpers as a library, kodvent. It had gcd and lcm, a disjoint set union, a segment tree and binary search, but not the code for maps and shortest paths, which I need most often. Now version 0.4.0 is out. It is the largest update so far, and it adds this code: grids, bfs and dijkstra, and a heap.

val maze = input.toGrid()  // input: List<String>
val start = maze.positionOf('S')

// The fewest steps from the start to every cell that can be reached
val steps = bfs(start) { p -> maze.neighbors(p).filter { maze[it] != '#' } }

// Dijkstra's algorithm, when entering a cell costs its digit
val risk = levels.toGrid { it.digitToInt() }  // levels: lines of digits
val costs = dijkstra(Position(0, 0)) { p -> risk.neighbors(p).map { it to risk[it] } }

A state of a search does not have to be a cell. It can be a cell with a direction, a bitmask or any data class.

To check that the library really helps, I rewrote 3 of my old solutions with it:

  • 2025 day 4: 49 lines became 19
  • 2024 day 18: 36 lines became 12
  • 2024 day 16, both parts: 108 lines became 16

The documentation shows both versions of each solution. It has spoilers for these 3 puzzles and for part 1 of 2025 day 10.

The library is Kotlin Multiplatform, has no dependencies and is published on Maven Central. It needs Kotlin 2.4.0 or newer:

implementation("io.github.dmitrynekrasov:kodvent:0.4.0")

I would like to know what you write again every December and what is missing in the library.


r/adventofcode • • 2d ago

Meme/Funny every time

104 Upvotes

r/adventofcode • • 3d ago

Other If anyone is prepping for AoC this year and wants some warm up questions, have a look at this.

Thumbnail systemscheck.dev
55 Upvotes

Hello fellow nerds, I’ve been working on this programming puzzles website for a few months now, there are 13 puzzles live with another 3 releasing over the next few weeks (specifically won’t overlap with AoCs runtime). I’ve been roughly publishing a puzzle every two weeks since launching, I plan to take a break now and start again in late January. If you are looking for a fix of programming puzzles either before or after AoC, I hope you check it out. I personally can’t want for AoC this year, the most wonderful time of the year! Cheers folks


r/adventofcode • • 3d ago

Visualization [2026] Advent of Code Charts browser extension updates

30 Upvotes

Aloha folks! I've been operating the "Advent of Code Charts" browser extension for private leaderboards since 2018, and I typically do a round of fixes and updates just before the new event. You can get v8.0.0 in different ways:

There's been several community contributions (in the form of issues, suggestions, code, etc), some of the highlights include:

  • Performance improvements for huge leaderboards
  • Better 12-day support, and visual hints in graphs what the "puzzle days" are
  • Chart 2 => subtly show the "cumulative total stars" of the total leaderboard
  • Chart 4 => completely revamped to a fully delta-time (diff between part 2 and 1) focus
  • Chart 4 => subtly show the 'typical'/average delta-time, to see how you compare to the rest
  • User script (experimental) support
  • A few bugfixes and smaller improvements

Here you can see how (for a 12-day event) the background subtly changes color from day 13 onwards in chart 1, so you can get a feeling for who puzzled around release days, and who completed puzzles later on:

Points per Day chart with new background visuals

And here is an example of what chart 4 will look like (logarithmic scale of sorts, averages for the leaderboard, signed in user + top 2 other players enabled by default) with dummy data halfway through a 12-day event:

Delta-time chart with averages for the leaderboard

Finally, my own favorite part: the delta-time "leaderboard". Unchanged except for bugfixes, but worth to highlight it once over. This table can bring back some private leaderboard competition that is timezone-friendly! Assuming everyone plays fair on your leaderboard (no peeking ahead etc.) it allows you to compete for fastest solve time of part 2, starting the clock after solving part 1. That means you can start a puzzle whenver it best fits your personal life and timezone. An example with dummy data:

Delta-time leaderboard based on dummy data

If you have any questions, suggestions, bugs, or whatnot: either post them here or submit an issue on the GitHub repository.

Happy puzzling!


r/adventofcode • • 3d ago

Tutorial [2016 Day 22 Part 2] Solving the problem in front of you

3 Upvotes

There's a bit of advice floating around that you don't have to solve the general case, only the problem in front of you. And, well, I've been working through past years, and 2016 Day 22 felt like a really good example that, so I thought I'd turn it into a tutorial about what that means.

In the general sense, you're given something similar to a 15 Puzzle. There's a grid of data nodes, you can transfer data between adjacent ones, and you need to get the data from the top right to the top left. Except... the numbers are a red herring. There are really only 4 numbers. Empty, small enough to fit onto any node, large enough to fit more or less anything, and massive enough to be a wall. The explanation for part 2 even calls attention to this by reducing the nodes to three states - empty, filled, and wall.

So already, my first instinct was to plot things and see where the walls are... and there was just a contiguous wall cutting across one of the rows, with everything else free. That makes things a lot easier.

If the empty square is already next to the data, you can just do loop-de-loops to slide it along. For example, from

..G_
....

it takes 4 moves to move the empty square around G to

._G.
....

it takes 1 move to shift G over

.G_.
....

and then it takes another 5 moves to shift it over by 1 again

G_..
....

So if I've already moved the empty space to the starting space for the data, the remaining moves are just 5*(cols - 2)... because the entire first 2 rows are free of walls. And all you have to do is use your pathfinding algorithm of choice to move the empty space there, then add that constant.

There are ways this could have been made more difficult. If there were walls on row 1, I would have had to do actual pathfinding for moving things along. If there were walls on row 0, I would have had to move the data in a more complicated path. If there were multiple blocks of data that needed moved around, it would have been more complex to optimize. But because the problem was nicely arranged to make things easier, I was able to streamline the solution.


r/adventofcode • • 3d ago

Help/Question - RESOLVED [2016 Day 17 Part 2] Why am I getting infinitely many paths?

2 Upvotes

Ignore some of the scaffolding. My code's set up so I can benchmark it with JMH if I want to, which is why everything's a method that returns a Long, or why I have a State## object that just stores the input as an array of strings.

I'm representing each state as a pair of an IntVector and a String. IntVector is what it sounds like and just makes it more convenient to, say, change a coordinate by 1 for moving up or down, and then the String is obviously the path. getOpenDoors takes the password, my current position, and the path so far and determines which doors are unlocked, automatically filtering things so it won't try to progress from the target or step out of bounds. And for my loop, it first checks whether it's at the destination, then if it isn't, it calls getOpenDoors and adds all the possible next steps to the queue.

The only differences from my loop for part 1 are that instead of breaking after reaching the destination, it just continues. And then as part of figuring out what's going wrong, I switched removeFirst to removeLast to turn it into a stack/DFS instead of a queue/BFS. When I try logging things on the "bad" examples, like how hijkl ends in you getting trapped, it successfully terminates. But when I try it on an example like ihgpwlah it just keeps looping, instead of stopping at 370. Especially because of the DFS, it just blows up, and it hit the 3000s before I killed it.

Does anyone have an idea of what I'm missing? (It also doesn't help that 2016 is old enough that a lot of the pastes has expired or the threads will be littered with people scrubbing old posts, which makes it hard to look for advice)

fun part2(state: State17): Long {
    var res = 0L
    val queue = ArrayDeque<Pair<IntVector, String>>()
    queue.addLast(Pair(IntVector.of(0, 0), ""))
    while (queue.size > 0) {
        val (pos, path) = queue.removeLast()
        if (pos[0] == 3 && pos[1] == 3 && path.length > res) {
            res = path.length.toLong()
            println(path.length)
            continue
        }
        
        for (dir in getOpenDoors(state[0], pos, path)) {
            val nextPath = path + dir
            val nextPos = pos + when (dir) {
                "U" -> IntVector.UP
                "D" -> IntVector.DOWN
                "L" -> IntVector.LEFT
                else -> IntVector.RIGHT
            }
            queue.addLast(Pair(nextPos, nextPath))
        }
    }
    return res
}

fun getOpenDoors(password: String, pos: IntVector, path: String): List<String> {
    val md5 = (password + path).md5()
    val res = mutableListOf<String>()
    if (pos[0] != 3 || pos[1] != 3) {
        if (md5[0].code > 0x61 && pos[0] > 0) res.add("U")
        if (md5[1].code > 0x61 && pos[0] < 4) res.add("D")
        if (md5[2].code > 0x61 && pos[1] > 0) res.add("L")
        if (md5[3].code > 0x61 && pos[1] < 4) res.add("R")
    }
    return res
}

r/adventofcode • • 5d ago

Other Looking forward to AOC2026!

224 Upvotes

AI destroyed my motivation the last years, but now it is back! Looking forward to use my own brain cells again!


r/adventofcode • • 4d ago

Visualization [2024 Day 18] [Kotlin] Visualization with GraphMateKT

Thumbnail gallery
40 Upvotes

Around 2 years ago, Advent of code inspired me to add vizualization capabillities to my GraphLibrary: GraphMateKT. Now, I'm starting a youtube series, showcaseing it's capabilities, by solving old AoC puzzles, and hopefully, new ones. I'm looking forward to AoC 2026! For now, here's a vizualization of a breath first search on a partially blocked and fully blocked grid!


r/adventofcode • • 4d ago

Upping the Ante [2019 Day13] [Rust] - hunting for marginal speedups

3 Upvotes

While I'm waiting for Dec 1st I took a look at this one since it is one of the two slowest days of that year. I write in Rust, so my timings should be comparable to u/maneatingape. Unlike him I have a locally optimized version of my IntCode interpreter, which together with verifying that this particular day works fine with i32 instead of i64 elements have resulted in 1631 vs 2357 us as the benchmark.

https://github.com/TerjeWiigMathisen/aoc/blob/master/2019/day13/src/main.rs

Only 10 more days!


r/adventofcode • • 7d ago

Visualization [2019 Day 13 (Part 2)] ANSI Terminal Breakout

Post image
23 Upvotes

2019 day 13 featured an Intcode program which runs a game of Breakout; your code needs to move the paddle until all the bricks are cleared. Implemented in Rust thanks to this ANSI control code cheat sheet. An ASCII visualization option can also be selected by environment variable.


r/adventofcode • • 7d ago

Help/Question - RESOLVED need help solving 2015 day 3

8 Upvotes

lets ignore the fact I'm not freeing right now the allocated mem.
i have a problem that i get 5488 from the current implementation. what am i doing wrong

#include <stdio.h>
#include <stdlib.h>


typedef struct Field field_t;


struct Field
{
    field_t *up;
    field_t *down;
    field_t *left;
    field_t *right;
};


typedef struct Root
{
    field_t *root;
} root_t;


field_t *FieldCreate(field_t *connect_to, char side);

int main()
{
    char *data_input = ">^^v^<>v<<<v<v^>>.... "; i pasted here the input.
    size_t counter = 1;
    root_t head = {NULL};
    head.root = FieldCreate(NULL, 'q');
    field_t *current_pos = head.root;
    while (*data_input)
    {
        switch (*data_input)
        {
        case '>':
            if (current_pos->right == NULL)
            {
                ++counter;
                current_pos->right = FieldCreate(current_pos, '<');
                printf("%c", '>');
            }
            current_pos = current_pos->right;
            break;
        case '<':
            if (current_pos->left == NULL)
            {
                ++counter;
                current_pos->left = FieldCreate(current_pos, '>');
                printf("%c", '<');
            }
            current_pos = current_pos->left;
            break;
        case '^':
            if (current_pos->up == NULL)
            {
                ++counter;
                current_pos->up = FieldCreate(current_pos, 'v');
                printf("%c", '^');
            }
            current_pos = current_pos->up;
            break;
        case 'v':
            if (current_pos->down == NULL)
            {
                ++counter;
                current_pos->down = FieldCreate(current_pos, '^');
                printf("%c", 'v');
            }
            current_pos = current_pos->down;
            break;
        default:
            break;
        }
        ++data_input;
    }

    printf("%zu\n\n", counter);

  
    return 0;
}


field_t *FieldCreate(field_t *connect_to, char side)
{
    field_t *field = (field_t *)calloc(1, sizeof(*field));
    if (NULL == field)
    {
        puts("welp");
        return NULL;
    }


    switch (side)
    {
    case '^':
        field->up = connect_to;
        break;
    case 'v':
        field->down = connect_to;
        break;
    case '<':

        field->left = connect_to;
        break;
    case '>':
        field->right = connect_to;
        break;
    default:
        break;
    }
    return field;
}

r/adventofcode • • 8d ago

Other Wallpaper

Post image
255 Upvotes

r/adventofcode • • 9d ago

Past Event Solutions [2022 Day 6 (Part 2)][C++] O(14.n) solution

7 Upvotes

I decided I wanted to do something a little different for my latest revisit and I had an idea for an approach that I thought was quite neat. Looking that the naive all-pairs checks for a given index and the index immediately afterwards, there are a lot of those checks in common:

Check (X == x):

     vv
012345678

-Xxxxx---
--Xxxx---
---Xxx---
----Xx---

--Xxxxx--
---Xxxx--
----Xxx--
-----Xx--

Diff:

-d----d--
--d---d--
---d--d--
----d-d--

Each move forward we're discarding the result of the oldest check and adding one new one per offset. If we can cache those "per offset" results and progressively update them, we should be able to get an O(n) sweep through the message with a number of steps equal to the required length, per message element.

Switching over to a dynamic programming perspective, let's say that when we're evaluating "do we have a run of N distinct letters ending at this point" then we already have access to "do we have a run of N-1 distinct letters ending at this point". For a given point, we look to see if we've got a run of N-1 ending at that point, and also a run of N-1 ending at the point before:

?[-- run of N-1 --]
[-- run of N-1 --]?

We have a run of N if and only if both of those runs are present and the two ? characters are different.

In code, the core of the loop looks like:

for (size_t messageIndex = 0; PuzzleInput::PeekChar() != EOF; messageIndex++)
{
    ...
    seen[current] = PuzzleInput::GetChar();

    dp[0][current] = true;
    for (int32_t i = 1; i < requiredCount; i++)
    {
        bool aDisjoint = dp[i - 1][current];
        bool bDisjoint = dp[i - 1][previous];
        ...
        bool newCharUnequal = (seen[current] != seen[current - i]);

        dp[i][current] = (aDisjoint && bDisjoint && newCharUnequal);
    }
    if (dp[requiredCount - 1][current])
    {
        return messageIndex + 1;
    }
}

There's some additional faffing to make sure it doesn't fire early (initialise the seen buffer with the first character of the message so that it's definitely not distinct when counted) and I've used a power-of-two wrapping window to keep memory down, but that's more or less it.

It's not the fastest or smallest approach possible but I thought it was neat and that approach might come in as a useful tool in the arsenal in future, so I'm happy with it.


r/adventofcode • • 10d ago

Repo 524* repo

24 Upvotes

while preparing for this year, https://github.com/Fadi88/AoC
this is my repo with all stars from previous years , mostly in python, and from time to time c++ and rust
some problems were solved by hand , not everything is automated


r/adventofcode • • 14d ago

Other [2025 Day 12] In review (Christmas Tree Farm)

20 Upvotes

This is just a placeholder because I was shocked to see that /u/musifter has been banned and all their posts removed, from all of Reddit it seems, not just this sub. Just on the cusp of completing the monumental task of reviewing every AoC puzzle! What a loss to the sub that all those posts are now gone.

I hope they, and Musifter, can all be reinstated. I've messaged the mods to ask if they know what's up.


r/adventofcode • • 14d ago

Other [2025 Day 12] In Review (Christmas Tree Farm)

11 Upvotes

There being no other options to get deeper into the base, we take the ventilation duct. Which leads us into a cavern full of Christmas Trees, where the Elves have been working to finish decorating before the deadline. What they need from us is to figure out how many of the areas under the trees can fit the presents that are set to go there. The presents cannot be stacked... but can be rotated and flipped. And so we have a polyomino packing problem.

The input is in two sections. The first is a list of the 6 types of presents (polyominos). All of these in the example are heptominos that fit in a 3x3 square. That's also true of my input, except that one is a hexomino, and one a pentomino. The second section is 1000 lines, with a rectangle to fill followed by six numbers (the counts of each type of present to fit into that rectangle). All of these numbers are 2 digits. And so my first thoughts were that polyomino packing is an NP-complete problem, these numbers are looking big for that, and there's a 1000 of them. There needs to be some sort of cheese.

So I considered the 4x4 example in the text, where 2 U-heptominos get put together... resulting in less fragmentation loss (2/9 to 2/16). Maybe the game here was just to meet a certain level of efficiency? So looking at mine I could see ways to put things together to make more efficient rectangles, which would be easier to tile in bulk. Of course then there's the issue of meeting the counts of presents along side that (with the potential of getting into Gaussian elimination again).

But first, I figured that only a few of the 1000 would be tricky. So I decided to write a little exploratory script to just sort out the problems that didn't have enough space. I just quickly got the number of tiles in the presents (making use of =()= because it was a while since I'd used in for AoC);

foreach (@$desc) {
    my $num =()= m/#/g;
    $count += $num;
}
push( @sizes, $count );

Then just went through the presents testing for if the number of tiles required for presents was more than the area. This removed about 60%. Which was great, so I decided to look a bit closer and actually output the leeway to see the wriggle room (ie find the tight ones). Either an area was 1-3 short or 400-850 over (and the excess is always > 2.4 * #shapes). So I figured that was more than enough space to blindly put down presents and just submitted the count (which was correct).

Afterward, I added to the script the placing down (technically this "works" for test, in that it catches that it doesn't handle it... in theory an actual polyomino packing solver goes there):

my $tileGridSpots = int($width / 3) * int( $length / 3);

if ($tileGridSpots >= $numShapes) {
    $part1++;
} else {
    warn "Region with potential space we didn't prove found\n";
}

Since this puzzle is all cheese, it meant that I managed to get a star with dc on every day. In order to make this one have something to do, I did parse the input (using v1.4.1's ? extensively... the stack size z also gets a lot of fun use). Then I just do the basic area test:

tr '.#:x' '12  ' <input | dc -e'[q]sq?[z1<q???0[r[A~2/3R+rd0<D]dsDx+z2<I]dsIxr1+:p??z0<L]dsLx0[0z4-[d;p5R*3R+r1-d0<I]dsIx+4R4R*-d.1+/+?zRz1<M]dsMxp'

For part 2, as there's no global leaderboard to tell me my number, so I took my time and read it before submitting it. That was a nice consequence of that change. As for the switch to 12 days, that's fewer puzzles for Eric to make, but as I've said, that's also a lower granularity to put a difficulty curse on. So there needs to be more thought into that side of things, and I think this year did a good job of making sure there was a good number of puzzles accessible for beginners.

And so we come to the end of the review. AoC may have been a little bit rough to start (but 2015 was much better than I remembered), but it quickly found its footing and has been consistent ever since. Which is quite a feat. I'd like to thank everyone that's come along... it's been fun reading other peoples stories and about their solutions and approaches (and it added a bunch of things to the TODO of things to try and things to fix). I'd especially like to thank u/terje_wiig_mathisen for stepping in to cover a few days while I was traveling and dealing with things.

All there is now is to wait and prepare for December 2026.


r/adventofcode • • 14d ago

Other Web search Vs model ask

1 Upvotes

Well, I was just thinking that most of last year's, during AoC it was expected some web search and investigation trying to find some algorithms and formulas...

Nowadays,with AI, this search became obsolete, by default, browsers throw you AI answers, so I was wondering what is considered AI assisted, "cheating" or who knows how to call it, if you use agents in ask mode asking questions knowing exactly what you are looking for instead of doing classic Google search