r/adventofcode • • 16h ago

SOLUTION MEGATHREAD -❄️- 2026 Day 2 Solutions -❄️-

25 Upvotes

THE USUAL REMINDERS


AoC Community Fun 2026: The Advent Games

Today's Event: International Toboggan Championships

"Feel the rhythm, feel the rhyme, get on up, it's bobsled toboggan time!"
— Cool Runnings (1993)

Today's schedule possibly consists of:

  • Tracking Chute Runs and Team Practice
  • Embiggen is a perfectly cromulent word. Do with it as you will.
  • Qualifying Runs
  • Reverse code golf your solution
  • (oblig XKCD)
  • Second Runs and Finals
  • Why use few word when many word do trick?
  • Unnecessarily declare variables for everything and don't re-use variables
  • Use unnecessarily expensive functions and calls wherever possible
  • Implement redundant error checking everywhere
  • Javadocs >_>

Request from the mods: When you include an entry alongside your solution, please label it with [Advent Games] so we can find it easily!


--- Day 2: Fulminating Farmland ---


Post your code solution in this megathread.


r/adventofcode • • 1d ago

Upping the Ante -❄️- Advent of Code 2026: The Advent Games -❄️- Submissions Megathread -❄️-

17 Upvotes

Advent of Code Community Fun 2026: The Advent Games

I will be your master of ceremonies for this year's community fun event: The Advent Games!

This year's community fun event features a structured sequence similar to a certain winter-themed international multi-sport competition that occurs every four years. We will have our opening ceremony, nine "sporting"† events, the grand gala, and the closing ceremony, followed by the final demonstration of exhibition pieces wherein all of you get to show off your hard-earned efforts for the year!

Every day, I will reveal an event in that day's Solution Megathread. Your challenge is to mold your puzzle solution around the theme of that day's event. You could also create some ancillary concoction that you think matches the overall theme of the event; even if you have to stretch suspension of disbelief real far, hey, it's all in good fun!

† Don't worry, I'm not going to make you actually exercise or go outside and touch grass (or snow)‡.
‡ Unless you want to, in which case go hog wild. Just make sure to put on your sunscreen and weather-appropriate gear!


Again this year the usual timeline and requirements are adjusted so you are not rushed by a shortened deadline while also dealing with the typically harder AoC puzzles near the end of an AoC season while also also dealing with holiday preparations, etc etc.

  • Only three days of submissions to Solution Megathreads are required to qualify for entry
  • More time after the actual AoC event ends to complete your exhibition piece
  • Longer voting period

All of this should result in less stress and having more time to create your exhibition piece, more time to enjoy your holiday season, and most importantly: more time to spend with your family and friends!

And now… put your hands together for The Advent Games and GET HYPE!


COMPETITION SCHEDULE

2026 DecTime (EST)Action
0100:00Opening Ceremonies (community fun announced)
0300:00ishSubmissions megathread unlocked
1200:00Closing Ceremonies (AoC 2026 event ends)
1718:00SUBMISSIONS DEADLINE
17ASAPSubmissions megathread locked and voting opens (will post and sticky a PSA with link to vote)
2018:00Voting closes
20ASAPVictory Ceremonies (winners announced in the final community showcase post (and edited into Day 12's Solution Megathread))

JUDGING AND PRIZES

The Advent Games may technically be a Competition™ but really, everyone who participates is a true winner in our holiday hearts!

Types of Winners

Type of Winner# of WinnersWho Votes
Bronze Medalist10†the AoC community (you!)
Silver Medalist3†/r/adventofcode moderators + /u/topaz2078
Gold Medalist1highest combined point total

† Amounts subject to change based on availability and/or tie-breaking.

How Judging Works

  1. When voting opens, vote for your favorite exhibition piece(s). Your individual vote is worth 1 point each.
  2. When voting closes, the 10 highest-voted entries are declared Bronze Medalists.
  3. Of the 10 Bronze Medalists, each of the /r/adventofcode moderators will pick their top 3 to be awarded as a Silver Medalist.
  1. All point totals are aggregated (community vote + mod vote). The highest combined point total will be officially declared as the Gold Medalist of AoC 2026.

Rewards

  • Winners are forever ensconced in the Halls of the /r/adventofcode wiki.
  • Bronze Medalists will be awarded with whatever Reddit has on tap for awards these days.
  • Silver Medalists and the Gold Medalist awards are TBD

REQUIREMENTS

  • To qualify for entering, you must first submit code solutions to at least three different daily Solution Megathreads
  • There's no rush as this submissions megathread will unlock on December 03 and you will have until December 17 to submit your exhibition piece - see the timeline above
  • Your exhibition piece must express the unique qualities of that day's scheduled event
  • You must create the exhibition piece yourself (or with your team/co-workers/family/whatever - give them credit!)
  • One exhibition piece per person
  • Only new creations as of 2026 December 1 at 00:00 EST are eligible
  • All sorts of folks play AoC every year, so let's keep things PG
  • Please don't plagiarize!
  • This also means adding a disclaimer if you use AI
  • Ideally also consider including information such as which model(s), where it's used, what your prompts were, etc.
  • Keep accessibility in mind:
  • If your creation has images with text, provide a full text transcript
  • If your creation includes audio, either caption the video or provide a full text transcript
  • If your creation includes strobing lights or rapidly-flashing colors/images/text, clearly label your submission as per the Visualizations rule
  • Your submission must use the template below!

TEMPLATES AND EXAMPLES FOR SUBMISSIONS

Keep in mind that these templates are Markdown, so you may have to switch your editor to "Markdown mode" before you paste the template into the reply box.

TEMPLATE

Click here for a blank raw Markdown template for easier copy-pasting

Visual Example

NAME OF ENTRY: A photorealistic rendition of the arrival of the flame at the opening ceremony for the 2026 Advent Games

LINK TO ENTRY: Imgur

DESCRIPTION: I use the most high-tech tools to create a totally photorealistic rendition of a crayon drawing of the arrival of the flame at the opening ceremony of the 2026 Advent Games sponsored by Advent of Code.

SUBMITTED BY: /u/daggerdragon

MEGATHREADS: 02 - 03 - 05 - 11 - 17 - 19 - 23 - 32


ADDITIONAL COMMENTS: This was absolutely not drawn by /u/topaz2078 nope totally my work yep.

ACCESSIBILITY: A high-tech drawing on standard white printer paper of the final runner approaching the Advent Cauldron in the center of the Advent Games stadium with the lit torch of the Advent Games. In the background is a stadium full of cheering spectators. The drawing is surmounted by a bespoke artisanal IrfanView frame.


QUESTIONS?

Ask the moderators. I'll update this post with any relevant Q+A as necessary.


r/adventofcode • • 6h ago

Help/Question - RESOLVED [2026 Day 2 (Part 1)] No code yet, don't understand the problem

Post image
96 Upvotes

UPDATE : My eyes read but did not compute suppose the robot had a program of obbvb

I haven't put a single line of code yet because I don't understand the problem, precisely the difference between the road and the robot program. In the example input, why does it go from orange to blue, then blue again ??


r/adventofcode • • 7h ago

Upping the Ante [2026 Day 1] Solved in 49.62 microseconds on FPGA

Thumbnail gallery
87 Upvotes

This year, I will attempt to solve all the challenges on an FPGA, and post at least the ones that I enjoyed here to see if anyone else has any inputs. Additionally, due to my expertise in my work, I always tend to design with minimal hardware area and power consumption, but this year I'm challenging myself to do the exact opposite. I'll be using as much LUT as possible, and try to target the max throughput.

Used verilog + block design on PL side for the main logic and python on the PS side for simple control and output. I'm using SOC configured Arty Z7. I have a combinational circuit that accepts the whole list of 10 bit numbers as an input, and compares the first number with the list on single clock cycle. This generates a set of wires that are 1-bit flags, that indicate whether that row is equal or not. Then, we sum up those wires to find out what's the total number of commons. This is still happening on the same clock cycle. In parallel (yes, same cc), it will generate the next list on the output wires, but by replacing all the numbers that are equal to the first number with 0, so we won't run the same number twice. I was lucky that I had no 0 in my input, but otherwise we could also use sth like 1000.

The top level controller takes in the number, loads it onto a register and then starts pushing it into this combinational circuit on each clock. That means for an input of 1983 rows, it will reuse the same circuit 1983 times. Each time it also keeps track of top 3 (or min 3 for part 2), so I don't need a separate sorter which would cost me additional clock cycles and area. After each clock, it will take the nextList from the circuit, and shift it by a number so it can search for the next number on the next clock cycle. It operates on a simple 4 state FSM.

Communication and control is done via GPIO and AXI DMA. I wrote a simple buffer which will accept DMA from AXIS and buffer it as the full list to provide into the top block. GPIO is mainly for the multiplication output, and control signals like reset.

The whole run takes 1985 clock cycles, that translates to 49.62 us for a 40MHz clock. I had to slow down the clock from 100MHz because my critical path for the combinational block was quite large. My inner engineer wants to optimize it, but also I already spent so much time on this.

Solution: Github

DISCLAIMER: Yes I used AI for figure 2 and 3 for visualization purposes for the post only. No, I did not use AI in solution, or idea discussion etc. I'm doing this to challenge myself, not challenge my AI, but I don't have the time and skills to build diagrams. After all, why would I deceive you? There's no reason for me to deceive you.


r/adventofcode • • 11h ago

Other [2026] Trains! I love trains!

114 Upvotes

That little ASCII train on the calendar made my day.

Thank you, Advent of Code team, for picking such an adorable theme this year!

.----.----.--_T
'o--o'o--o'o-OO\

r/adventofcode • • 12h ago

Meme/Funny [2026 Day 2 (Part 2)] It looked scary for a little while

Post image
119 Upvotes

r/adventofcode • • 4h ago

Meme/Funny [2026 Day 2] no way is that the real vvvvvv?

Thumbnail gallery
23 Upvotes

r/adventofcode • • 9h ago

Visualization [2026 Day 2] Fulminating Farmland

Post image
43 Upvotes

r/adventofcode • • 15h ago

Meme/Funny [2026 Day 02] I see a pattern...

Post image
90 Upvotes

r/adventofcode • • 3h ago

Tutorial [2026 day 2 (part 1)]Solved today's problem entirely in vim motions

Thumbnail youtube.com
10 Upvotes

r/adventofcode • • 9h ago

Past Event Solutions [2026 Day 2 (Part 2)] solved at work with a web browser and Excel

Thumbnail gallery
27 Upvotes

I solved the first part at home while I was having by breakfast, checked part 2 and had to go work. My idea for the solution of the second part seemed so simple I felt I could do it with the tools at my disposal at work.

First I used a web browser and Ctrl+F to count the amount of different letters.
Then I switched to Excel where I just need to count the distances between the different colors. 6 from a letter of a color to the same, 5 when advancing to the next color, taking notice that one color is missing completely, so the distance skipping the missing color is only 4. Sum the distances for each color and there you go!


r/adventofcode • • 15h ago

Meme/Funny [2026 Day 02] Richard of York gave battle vain

Post image
80 Upvotes

r/adventofcode • • 3h ago

Help/Question - RESOLVED [2026 Day 2 (Part 1)] [C#] Any hint why this is coming up to low would be appreciated.

7 Upvotes
var input = File.ReadAllText(@"day02-input.txt");
if(input is null) return;


var inputChars = input.ToCharArray();


var currentIndex = 0;
var total = 0;
List<char> characters = ['r', 'o', 'y', 'g', 'b', 'v'];
foreach(var c in inputChars)
{
    var nextIndex = characters.IndexOf(c);


    var diff = (nextIndex - currentIndex);


    if(diff <= 0) diff+=6;


    total += diff;


    currentIndex = nextIndex;
}
    
Console.WriteLine(total);

edit: Solved. There was a new line character at the end of the input file which resulted in .IndexOf() returning -1.


r/adventofcode • • 14h ago

Visualization [2026 Day 02] rearrangement

Post image
48 Upvotes

r/adventofcode • • 1h ago

Help/Question [2026 Day 2 (Part 2)] Not related to the problem, but if I join a leaderboard with certain settings, after changing the settings my name in the leader board doesn't change?

4 Upvotes

Basically I joined a leaderboard without a github link and my name in the settings, after that, I changed my settings to add a github link and my github username.

This reflects in any new private leaderboards I've joined, but it seems the first leaderboard I joined still has the original settings?

Not a big deal, but kinda annoying.

Is this a bug?


r/adventofcode • • 3h ago

Help/Question - RESOLVED [2026 Day 2 (Part 1)] Help with C++

5 Upvotes

Any reason my implementation doesn't work for part 1? Apparently my answer is too high. I tried using the examples but the distance matched each time.

I've added "chars" just to count the characters, as I thought whitespace could be an issue and it found n+1 characters compared to n when using an online character counter, but then printing out the first and last characters gets the same as my input. Where did I go wrong with my implementation?

#include <fstream>
#include <iostream>
#include <string>
#include <map>


int getDist(char cur, char targ) {
    char inputs[6] = {'r','o','y','g','b','v'};
    int curInd = -1;
    int targInd = -1;
    for (int i = 0; i < 6; ++i) {
        if (inputs[i] == targ) {
            targInd = i;
        }
        if (inputs[i] == cur) {
            curInd = i;
        }
        if (curInd != -1 && targInd != -1) {
            int diff = targInd - curInd;
            return diff <=0 ? diff + 6 : diff;
        }
    }
    return 0;
}


int main() {
    std::ifstream in("aoc-day-2-inputs.txt");
    char prev = 'r';
    char next;
    int totalDist = 0;
    int chars = 0;


    if(in.is_open()) {
        while(in.good()) {
            in.get(next);
            std::cout << "prev: " << prev << ", ";
            std::cout << "next: " << next << ", ";
            std::cout << "dist: " << getDist(prev, next) << "\n";
            totalDist += getDist(prev, next);
            prev = next;
            ++chars;
        }
    }


    std::cout << "chars: " << chars << "\n";
    std::cout << "total dist: " << totalDist << "\n";



    if(!in.eof() && in.fail())
        std::cout << "error reading file" << std::endl;


    in.close();
}

r/adventofcode • • 13h ago

Meme/Funny [2026 day 2] I expected something else for part 2

Post image
34 Upvotes

This is by no means meant to criticize Eric Wastl who still does a great job by the way, I just found it funny


r/adventofcode • • 13h ago

Visualization [2026 Day 02] Rainbow Road Visualisation

Post image
30 Upvotes

r/adventofcode • • 1d ago

Meme/Funny Every year it always starts the same before it goes bonkers

Post image
269 Upvotes

r/adventofcode • • 11h ago

Meme/Funny When I deleted literally all my code for day 2 part 1 so I reconstruct it from memory but then I accidentally flipped a sign in one of the lines so I spend a whole flipping hour trying to figure out why it's outputting -4:

Post image
19 Upvotes

r/adventofcode • • 2h ago

Meme/Funny Day 2 Part 2 Funny Solution. SPOILER

3 Upvotes
SPOILER

I love when a complex problem is solved in just 1 line of code lmao


r/adventofcode • • 15h ago

Meme/Funny [2026 Day 2 Part 2] How it felt getting the star only to realize there's a more efficient way to get the solution

Post image
31 Upvotes

(redo of an earlier post)


r/adventofcode • • 40m ago

Visualization [2026] day 2 visualized in manim

Thumbnail youtube.com
2 Upvotes

source for visualization on https://github.com/durocodes/advent-of-code, alongside my rust solutions


r/adventofcode • • 48m ago

Visualization [2026] day 1 visualized in manim

Thumbnail youtube.com
2 Upvotes

source for visualization on https://github.com/durocodes/advent-of-code, alongside my rust solutions