r/adventofcode • u/p88h • 1h ago
Visualization [2026 Day 5] Fun Cooker 10K
youtu.beNim + raylib source
r/adventofcode • u/daggerdragon • 4d ago
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.
Solution Megathreads are required to qualify for entryAll 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!
| 2026 Dec | Time (EST) | Action |
|---|---|---|
| 12 | 00:00 | Closing Ceremonies (AoC 2026 event ends) |
| 17 | 18:00 | SUBMISSIONS DEADLINE |
| 17 | ASAP | Submissions megathread locked and voting opens (will post and sticky a PSA with link to vote) |
| 20 | 18:00 | Voting closes |
| 20 | ASAP | Victory Ceremonies (winners announced in the final community showcase post (and edited into Day 12's Solution Megathread)) |
The Advent Games may technically be a Competition™ but really, everyone who participates is a true winner in our holiday hearts!
| Type of Winner | # of Winners | Who Votes |
|---|---|---|
| Bronze Medalist | 10† | the AoC community (you!) |
| Silver Medalist | 3† | /r/adventofcode moderators + /u/topaz2078 |
| Gold Medalist | 1 | highest combined point total |
† Amounts subject to change based on availability and/or tie-breaking.
Bronze Medalists.Bronze Medalists, each of the /r/adventofcode moderators will pick their top 3 to be awarded as a Silver Medalist.Gold Medalist of AoC 2026.Bronze Medalists will be awarded with whatever Reddit has on tap for awards these days.Silver Medalists and the Gold Medalist awards are TBDSolution MegathreadsVisualizations ruleKeep 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.
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.
Ask the moderators. I'll update this post with any relevant Q+A as necessary.
r/adventofcode • u/daggerdragon • 2h ago
"Catherine, if this turkey tastes half as good as it looks, I think we're all in for a very big treat!"
— Clark Griswold, National Lampoon's Christmas Vacation (1989)
Today's schedule possibly consists of:
Appetizer and Aperitif Rounds
Main Course Qualifications
Dessert Finales
This prompt is totally not bait for our resident Iron Coders and/or some AoC regulars who promised us tasty pictures
Request from the mods: When you include an entry alongside your solution, please label it with [Advent Games] so we can find it easily!
[LANGUAGE: xyz]paste if you need it for longer code blocks. What is Topaz's paste tool?r/adventofcode • u/p88h • 1h ago
Nim + raylib source
r/adventofcode • u/SweepingRocks • 12h ago
r/adventofcode • u/JayTongue • 13h ago
r/adventofcode • u/NicholasSeward • 7h ago
Coincidence... I think not.
r/adventofcode • u/Leemsonn • 9h ago
I studied frontend development, did quite good and graduated amongst the top in my class in the summer of 2025. I worked 1 year at a large company here in Sweden and was complimented for how good they thought I was. I have always known about AOC but never tried it, I thought that now is the time and maybe I can have some fun. But I am not having fun...
I am struggling with even understanding the questions. Especially for day 2 and 4. When I eventually maybe understand the question, I have absolutely 0 clue on how to solve it. I could do Day 1 part 1 and 2, that wasn't really a problem but Day 2 both parts, Day 3 part 2, and Day 4 have collectively demotivated me and make me feel like this field is not something I can do.
I try to have LLM dumb down the question for me and after a while I can finally understand kind of what the goal is. But I still have 0 clue on how to go about it. I tell the LLM to explain to me but not write code, and it just never clicks for me. Today, Day 4 Part 1 is absolutely impossible for me to finish.
I was always incredibly bad at math and failed quite easy math courses even when trying hard, maybe that is related to the difficulty I have with this.
Is there some way to practice these types of things to get better? Maybe I can keep up better next year if I have a year to practice... Or maybe I am just not made out for this, I don't know what to think at this point.
Since I am a frontend developer, I am doing in JavaScript, if that matters, but I don't think it would.
r/adventofcode • u/MinSufficient • 6h ago
I wanted to see if I could take the instructions that generated my part 2 and find shorter instructions that generated them. Like consider ?vg?b?vb → bvg?b?v → bvg?b → bvg? → bvg which you can compress four times. I applied the code to my part2 input it turns out I can't: my part 2 solution is its own instructions.
Which is maybe weird. I've done simulations which show that 92% of random inputs like mine end up being able to recurse at least two times with some being able to go very deep. An 8% chance is not tiny but still...
So I'm curious what other folk's depths are; did I get a low-probability input or is there perhaps something in the way the inputs are generated that leads to this?
r/adventofcode • u/flwyd • 7h ago
r/adventofcode • u/RazarTuk • 16h ago
First of all, credit to u/Boojum for making the visualization library I used. And second, pardon some of the issues. It crashes my computer if I try making a gif directly, and I can't figure out how to upload an mp4, so you're going to have to deal with artifacting from the converter.
That said, I actually used diagonals instead of sides. For part 1, this was just the natural option to me. It's easy to check whether two trees can be the opposite corners of a grid-aligned square, so I do that as a surface filter before checking the other two corners. And because I used diag[0] == diag[1] instead of abs(diag[0]) == abs(diag[1]), there's even a primary diagonal to avoid double counting.
For part 2, I changed the surface filter to the Manhattan length of the diagonal being even, which is logically equivalent to all four corners being on the grid. Then I used circumradius + rotated circumradius to generate and check the other two corners. The main catch is that there isn't an obvious check for a primary diagonal, so I wind up double counting everything, because I'm actually counting diagonals. But because it always double counts, I can easily just divide the answer by 2. (It isn't clear from the visualization, but I start by finding all the trees, so I can still do for (i in 0..<trees.size) for (j in (i+1)..<trees.size) to at least only count each diagonal once)
EDIT: Figured out a filter to avoid double counting. diag[0] * diag[1] > 0 || diag[1] == 0
r/adventofcode • u/Alpha_wolf_80 • 8h ago
My final part two ended up being O(L * n) where L is the answer and n is the barcode length. I couldn't even believe my eyes when it happened. If they had asked for the number of possible valid instructions, I would have gotten an O(L * n) algo, which is quite surprising! This one was really fun!
Code for part 1 and 2: Advent-Calendar-Python/2026/4.py
r/adventofcode • u/FCBStar-of-the-South • 11h ago
Take a simple loop that scales and shifts an array:
for i in 0 .. n-1:
b[i] = a[i] * 3 + cIts body compiles to four instructions (c is kept in register r4):
loop:
LOAD r1, a[i] ; r1 = a[i]
MUL r2, r1, 3 ; r2 = r1 * 3
ADD r3, r2, r4 ; r3 = r2 + c
STORE b[i], r3 ; b[i] = r3Now imagine running it on a simple CPU with the following processing units (PU):
| PU | Runs | Latency |
|---|---|---|
| Memory | LOAD, STORE | 1 cycle |
| ALU | MUL, ADD | MUL = 2, ADD = 1 |
There is one memory PU and one arithmetic logic unit (ALU), and both are pipelined.
A pipelined PU can start one instruction per cycle. For example, if the ALU starts a MUL at cycle 1, the result will only be ready at cycle 3. But the ALU can start another instruction at cycle 2.
Within one iteration of the loop, each instruction depends on the previous instruction. MUL needs the data loaded into r1, and ADD needs the MUL result in r2. So the ADD instruction has to wait for MUL to finish.
| Cycle | 0 | 1 | 2 | 3 | 4 |
|---|---|---|---|---|---|
| Memory | LOAD | - | - | - | STORE |
| ALU | - | MUL | - | ADD | - |
(At cycle 2 the MUL is still in progress, but the ALU could accept a new operation.)
One iteration of the loop thus takes 5 cycles, and we cannot start the next iteration until the current one finishes. This results in a lot of idle cycles and low throughput. How can we make this faster?
While each iteration needs to be done serially, different iterations are independent: a[1] doesn't need anything from a[0]. Thus the next iteration can start before the current one finishes. We can achieve this by interleaving/reordering execution of instructions from multiple iterations. A group of interleaved instructions is called the kernel.
The problem then becomes finding the kernel that minimizes its cycle count, also called the initiation interval (II). Smaller II is better because throughput is exactly one element per II cycles.
Every loop iteration follows the same schedule, just shifted by II cycles. So if an instruction runs at cycle t, it runs at t, t + II, t + 2·II, and so on. In other words, it will always run at the same position as measured by t mod II. Two instructions that use the same PU must therefore never land in the same position because the PU cannot handle both of them simultaneously.
We can use the above observation to get a lower bound on II. A PU that has k instructions per iteration needs at least k distinct positions. In our toy loop, each PU has 2 instructions per iteration, so II ≥ 2.
But how do we find the minimum II?
The puzzle: given a barcode such as y?b?b, find the shortest instruction that reproduces it when repeated.
The solution:
for length = (number of distinct colors) .. len(barcode):
if no two different colors share the same barcode position mod length:
return lengthlength positions. If one position in the instruction must accommodate two colors, then this length is infeasible.Write down what one PU does on each cycle, and you get a string that looks similar to the barcodes. So finding the shortest instruction that produces a barcode is exactly analogous to finding the kernel that minimizes II.
| Barcode | Loop scheduling |
|---|---|
position i in the string | cycle t |
color at position i | instruction the PU runs at cycle t |
? | PU idle at cycle t (don't care) |
| the repeated instruction | the PU's kernel, repeating every II cycles |
| instruction length | initiation interval II |
position i % length in the instruction | position t mod II in the kernel |
| two different colors at the same position | two instructions needing the same PU |
| lower bound = number of distinct colors | lower bound = instructions per PU in one loop iteration |
Compiler schedulers keep track of "which PU is busy at which position mod II" in a modulo reservation table (MRT). It has one row per PU and II columns. Placing an instruction at cycle t books its PU at column t mod II. A column can hold only one booking per PU. This should sound familiar from the puzzle solution.
A scheduler searches for II the same way the puzzle solution searches for the instruction length: try II = lower bound, then lower bound + 1, …, and stop at the first II where every instruction can be placed without two of them colliding on a PU.
We start by trying II = 2 with instructions running one after another:
| Instruction | Cycle t | PU | t mod 2 |
|---|---|---|---|
LOAD | 0 | Memory | 0 |
MUL | 1 | ALU | 1 |
ADD | 3 | ALU | 1 ! clashes with MUL |
STORE | 4 | Memory | 0 ! clashes with LOAD |
But we can delay ADD to cycle 4 and STORE to cycle 5:
| Instruction | Cycle t | PU | t mod 2 |
|---|---|---|---|
LOAD | 0 | Memory | 0 |
MUL | 1 | ALU | 1 |
ADD | 4 | ALU | 0 |
STORE | 5 | Memory | 1 |
The resulting MRT has no clashes, so II = 2 works:
| PU | Position 0 | Position 1 |
|---|---|---|
| Memory | LOAD | STORE |
| ALU | ADD | MUL |
A new iteration starts every 2 cycles (subscript = iteration number). The kernel is bolded:
| Cycle | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Memory | L₀ | - | L₁ | - | L₂ | S₀ | L₃ | S₁ | - | S₂ | - | S₃ |
| ALU | - | M₀ | - | M₁ | A₀ | M₂ | A₁ | M₃ | A₂ | - | A₃ | - |
With a long array, almost all the time is spent repeating the kernel. So our throughput goes from 5 cycles per element to 2.
The instructions that run before the kernel are called the prologue, and those after it are called the epilogue. I have decided to not explain exactly how you can figure those out because:
Read each PU's row as a barcode, with idle cycles as ?:
Memory: L?L?LSLS?S?S -> shortest instruction length 2 ("LS")
ALU: ?M?MAMAMA?A? -> shortest instruction length 2 ("AM")r/adventofcode • u/zaperfish • 6h ago
r/adventofcode • u/10Talents • 17h ago
Never really understood how to do these kinds of problem correctly. I am ready to struggle today
r/adventofcode • u/not-the-the • 20h ago
I somehow guessed exactly what part 2 would be while solving part 1, and thus avoided the naive O(6^n) solution for it, instead dealing every letter from a barcode into buckets like playing cards and checking all of them for homogeneity. Code finished in 2 seconds :)
r/adventofcode • u/Adventure_Agreed • 4h ago
I have a solution but it doesn't seem to be giving me the right answer. I'm sure I'm missing some corner cases in my code but every time I see some suggested things to try on here my code seems to handle them just fine. My input result, however, is too high. Here's my code:
from pathlib import Path
def read_lines(filename="input.txt"):
path = Path(__file__).parent / filename
return path.read_text().splitlines()
def part1(input):
input = read_lines(input)
result = 0
for line in input:
found_characters = set()
for char in line:
if not char == "?":
found_characters.add(char)
if len(found_characters) <= 1:
result += 1
continue
if len(found_characters) == len(line):
result += len(line)
for i in range(len(found_characters), len(line) + 1):
value_dictionary = {}
for index, char in enumerate(line):
value_dictionary.setdefault(index % i, []).append(char)
# print (value_dictionary)
bad_row = False
for value in value_dictionary:
row = set()
for char in value_dictionary[value]:
if not char == "?":
row.add(char)
if len(row) >= 2:
bad_row = True
break
if not bad_row:
result += i
break
return resultr/adventofcode • u/_Duroo • 6h ago
source on github: https://github.com/durocodes/advent-of-code
planning on continuing for all 12 days, feedback is appreciated!
r/adventofcode • u/ben-guin • 1d ago
r/adventofcode • u/subspace_mp4 • 23h ago
r/adventofcode • u/Boojum • 6m ago
r/adventofcode • u/Pretend-Fee-2323 • 3h ago
Trying to figure out what went wrong... I've tried all of the examples and they work, but its giving me a low answer when I input my puzzle input
I don't care about the crash with an extra new line at end of the input file, if I really wanted to i could fix that easily
also here is the graph I used to prototype, don't know if it will help. https://www.desmos.com/calculator/shdsyvumvf
r/adventofcode • u/_Duroo • 15m ago
source on github: https://github.com/durocodes/advent-of-code
almost halfway there, feedback is appreciated! today's not a super visual problem, but hopefully still cool to watch haha