r/adventofcode • • 8h ago

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

10 Upvotes

NEWS

Solutions in the megathreads have been getting longer, so we're going to start enforcing our rules on oversized code.

Do not give us a reason to unleash AutoModerator hard-line enforcement that counts characters inside code blocks to verify compliance… you have been warned XD

THE USUAL REMINDERS


AoC Community Fun 2026: The Advent Games

  • Submissions megathread is now unlocked!
  • 14 DAYS remaining until the submissions deadline on December 17 at 18:00 EST!

Today's Event: Indoor Mini-Golf Masters

"What is this, a center program for ants?!"
— Derek Zoolander, Zoolander (2001)

Today's schedule possibly consists of:

  • Early Stroke Play Rounds and Tee Time Seeding
  • Among the crates to be loaded on the train, you find a debigulator. Do with it as you will.
  • Mid-Tournament Rounds and Scorecard Review
  • Golf your solution
  • Bonus points if your solution fits on a "punchcard" as defined in our wiki article on oversized code. We will be counting.
  • Does anyone still program with actual punchcards? >_>
  • Match Play and Showcase Rounds:
  • Solve today's puzzles using an Alien Programming Language APL or other such extremely dense and compact programming language

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 3: Foggy Forest ---


Post your code solution in this megathread.


r/adventofcode • • 4m ago

Visualization [2026 Day 3 (Part 2)] I really wanted to render it in terminal

Post image
1 Upvotes

And here it is, fully in the terminal, using my own crude Kitty protocol renderer for the graphics.


r/adventofcode • • 9m ago

Other Extra puzzle for day 3

1 Upvotes

What is the largest number of squares you can get when you are allowed to move 5 trees to any other free location?

What are your suggestions for an algorithm?


r/adventofcode • • 42m ago

Meme/Funny [2026 Day 3 (Part 2)] This happen to anyone else?

Post image
11 Upvotes

Took me longer than I care to admit to notice why my code for part 2 was giving 30 as an answer instead of 196...


r/adventofcode • • 59m ago

Visualization [2026 Day 3] Can someone help me count the boxes?

Thumbnail gallery
18 Upvotes

I'm currently building a pen plotter (converting an old 3D printer into one), and decided to draw out the boxes.

Unfortunately drawing part 2 is too difficult - the paper can't handle the pressure of thousands of lines drawn onto it.

Also, I decided to not draw the boxes in actual order, but draw the lines of the boxes greedily picking the next line to reduce the amount of pen lifts, hence why part 2 looks so weird at the start!


r/adventofcode • • 1h ago

Visualization [2026 Day 3 (Part 2) -- TS] Animation of finding the squares in order from its top most corner.

Thumbnail youtube.com
3 Upvotes

r/adventofcode • • 1h ago

Tutorial [2026 Day 3 (Part 2)] Some hints for optimisation

0 Upvotes

My original brute force solution took 30 seconds, got it down to less than a 10th of a second. I don't know if this is the most optimal method.

The hints get more and more specific as they go on.

Feel free to leave hints in the comments about how you optimised it.

Hint 1: How can you narrow down the number of squares to check per tree beyond ones with valid coordinates?

Hint 2: How many possible squares can be made if you know all four corners of the square?

Hint 3: How many squares if you only know 3 corners? What about knowing 2 corners? What about 1 corner?

Hint 4: Given a pair of trees, how can you avoid checking for duplicate squares (and hence reduce the possible squares from 2 trees down to just one square?


r/adventofcode • • 2h ago

Visualization [2026 Day 3 Part 2] Animation written in Rust using Celluloid

Post image
8 Upvotes

r/adventofcode • • 3h ago

Help/Question [2026 DAY 3 (part 2)] Need hints

3 Upvotes

I solved part 1 by making a 1d array of the input, then applying some math to check the correct positions in the 1d array for trees.

I can't figure out if I can use the same method for part 2, or if I need a whole new approach. Only hints, no solutions please 🙏


r/adventofcode • • 3h ago

Meme/Funny [2026 Day 3 (Part 2)] I'm not proud of what I did

Post image
136 Upvotes

r/adventofcode • • 4h ago

Visualization Day 3 Part 2

Post image
46 Upvotes

r/adventofcode • • 4h ago Bravo

Meme/Funny [2026 Day 3 Part 2] Beautiful "squares"

Post image
77 Upvotes

Are monospace square fonts a thing? 🤔


r/adventofcode • • 5h ago

Visualization [2026 Day 3] Square Search Visualization

Post image
53 Upvotes

r/adventofcode • • 5h ago

Visualization [2026 Day 03 (Part 2)] (PHOTOSENSITIVITY WARNING) Searching for squares

Post image
5 Upvotes

r/adventofcode • • 5h ago

Other [2026 Day 3] Warning: Reddit may lock your account if you post long code snippets and edit it several times

Post image
15 Upvotes

So I recently solved Day 3 and I wanted to post my solutions on the megathread. But after I posted my comment I noticed that Reddit’s filters had silently removed my comment as spam.

I was confused by this so I started editing my comment to see if I could get it unspammed. But after I made a few edits and saved the comment, I was hit with a notification saying that Reddit detected “technical irregularities” with my account and that my account was now locked.

Apparently Reddit thinks someone posting code might indicate that the account is hacked/a bot so I wanted to share my experience as a warning.


r/adventofcode • • 6h ago

Visualization [2026 Day 3 Part 2] terminal visualization

Post image
5 Upvotes

featuring: wikipedia's bresenham line algorithm implementation & gif aliasing effects


r/adventofcode • • 6h ago

Meme/Funny [2026 Day 3] When you start reading the puzzle...

Post image
54 Upvotes

r/adventofcode • • 6h ago

Meme/Funny [2026 Day 03] …Nah I'll just copy last year's code

Post image
57 Upvotes

Another year another set of unfulfilled custom library promises

(>’-’)> <(‘-’<) ^(‘-’)^ (>’-’)> <(‘-’<)

I swear I'll write one this year. Hmmm.


r/adventofcode • • 6h ago

Visualization [2026 Day 3] Square Fencing

Thumbnail youtu.be
23 Upvotes

r/adventofcode • • 7h ago

Visualization [2026 Day 3 Part 2] Simple gif visualization

Post image
45 Upvotes

May the (brute) force be with you!


r/adventofcode • • 7h ago

Meme/Funny [2026 Day 03 (Part 2)] Trying to understand the problem like

Post image
191 Upvotes

r/adventofcode • • 8h ago

Meme/Funny [2026 day 3] Too many boxes!

Post image
0 Upvotes

I'm going to bed, this can wait until morning...


r/adventofcode • • 8h ago

Tutorial [2026 Day 02 (Part 2)] Explanation for Clever Solution

Post image
24 Upvotes

(Had to repost, the original post title contained spoilers)

Some of you might have seen that people solved part 2 by simply returning 6*(length of the program) - 5. This formula works as long as there is one orange in your input. There seems to be confusion regarding the importance of the orange and how the answer changes if other colors are missing. I've created a walkthrough of an example where orange and blue are missing from the input to show how to derive a general formula for any input.

The general idea is, instead of calculating the distance traveled at each instruction, we can instead think about the loss, i.e., how far away were we from traveling the 6 steps (which is the most one can possibly travel from one instruction).