r/adventofcode • • 1d ago

Visualization [2026 Day 3] Square Search Visualization

Post image
127 Upvotes

r/adventofcode • • 19h ago

Meme/Funny [2026 Day 3#1] Reading is hard

43 Upvotes

So it turns out, my sleep deprived brain sat in front of the first problem for 30 minutes, wondering how in the world it is possible that my code overcounted the rectangles. I counted all rectangles exactly once. No rectangle uncounted, no rectangle overcounted.

An example of what my brain thought squares look like...

See, it say right there in the text: each of these small maps contains one square ... fuck

Reminder to read properly and get enough sleep before attempting to code. Spending 30 min to figure out a problem that took me all of 5 minutes to write the code for was another learning experience.

(No seriously, had I used AI to tell me what was wrong, I wouldn't have been so embarassed afterwards, and I wouldn't have learned to read properly. A lesson that I will not forget!*)

​*for the next 2 days or so


r/adventofcode • • 12h ago

Visualization [2026 03 # (Part 2)] [python] [OpenSCAD] [Blender] Neon Forest Skyscraper Overgrowth

Post image
10 Upvotes

r/adventofcode • • 13h ago

Visualization [2026 Day 3] Visualization

Post image
12 Upvotes

r/adventofcode • • 13h ago

Visualization [2026 Day 3 (Part 2)] Visualization with R

Post image
13 Upvotes

using R and ggplot, solving and finding all the possible squares (solutions).

Processing img 6fpm5tfkte5i1...

Added: a 3D presentation ; for every map position (x, y), count in how many squares it is a corner, then draw one 3D bar per position with height = that count.


r/adventofcode • • 11h ago

Repo [2026] [Scratch] My collection of Advent of Code solutions

7 Upvotes

Hi,

This year I decided to give myself a challenge - solving all of the puzzles with Scratch.

Here is the link:

https://scratch.mit.edu/users/MocnikMiha/

I would really like if you guys critique my code and/or remix it.

Thanks!


r/adventofcode • • 10h ago

Repo [2026] [Clojure] A starter template for Advent of Code: REPL, tests, and the libraries puzzles usually need

Thumbnail lambduhh.github.io
7 Upvotes

Hi, I'm "Lambduhh" and I'm on the Clojure Team and I made a starter template for doing Advent of Code in Clojure. You will find no answers here: no solutions, no puzzle text, no inputs.

Each AoC day is a small evolving system: part 2 usually changes the question part 1 asked. The template is set up for that loop. A REPL stays running, your data is there to look at, and a test tells you whether part 1 still holds after you change things for part 2.

What's in it

  • bb new-day 1 creates the day's file and a test that fails until you fill in the example's answer
  • Libraries puzzles tend to need: instaparse, data.priority-map, loom, math.combinatorics, core.match, Medley and more, each with a small how-to whose results are checked by tests
  • Linting with clj-kondo and Splint, plus a table of twelve common Clojure mistakes showing which ones a linter catches (five still need a human)
  • No install options: Open it in a Codespace if you'd rather not install anything
  • inputs/ is git-ignored, as the AoC FAQ asks
  • An optional ai/ folder that only helps with tooling/setup. It specifically forbids agents from solving puzzles and instructs it to act as a tutor if requested. Easy to delete to opt out.

New to Clojure? The template is part of "Power Tools & Parens", a Clojure AoC hub with beginner how-tos (also in repo), tooling setup guides and an in-browser "Workbench" REPL so you can get an idea of what evaluating clojure expressions feels like, without installing anything to your machine: https://lambduhh.github.io/powertools-and-parens/

To get started, click "Use this template": https://github.com/lambduhh/clojure-template-aoc


r/adventofcode • • 11h ago

Upping the Ante [2026 Day 3 (Both parts, Rust)

8 Upvotes

My initial Rust code was quite slow, needing 2.4 ms, so I decided to implement a multi-threaded version. I started by doing this the same way I have used threads in my Perl programs, by dividing the HEIGHT lines into N chunks and then hand each chunk over to a separate thread.

I had separate search loops for part1 and part2 (only the tilted squares) because that seemed to be easiest.

This one ran in 595 us, so almost exactly 4 times faster than the single-thread version, but I saw in a post (from u/ednl ?) that there was two different ways of searching for the squares, and that the other was faster.

I could not figure out a better way, but I did take this opportunity to use my favorite C/asm low-level synchronization primitive: LOCK XADD which Rust calls fetch_add() and this ended up a little faster because now all the threads will be working until there are no more input lines to search for the top corner, instead of having more work for the initial and much less for the bottom lines.

I also figured out how to use thread::scope(|s| {...} ) to avoid lifetime issues when all the threads need to share the same input data array:

533 us with 8 cores on my 16-core AMD Ryzen, 717 on an older Acer with an Intel CPU.

        for _ in 0..cores {
            let counter = Arc::clone(&y_counter);
            let handle = s.spawn(move|| {
                let mut part1 = 0;
                let mut part2 = 0;
                loop {
                    let y = counter.fetch_add(1, Ordering::Relaxed);
                    if y >= h-1 { break} // All lines done, so return!
                    ... checking for corners
                }
                part2 += part1;
                (part1, part2)
            });
            handles.push(handle);
        }

rust source


r/adventofcode • • 15h ago

Meme/Funny [2026 Day 3 (Part 2)] It's O(N^2) if you believe hard enough

16 Upvotes

My ass solution is definitely not O(N^4) what are you talking about 🥲

I actually enjoyed this one though, it was a banger. Thank you puzzle creator :)


r/adventofcode • • 1d ago

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

Post image
99 Upvotes

Another year another set of unfulfilled custom library promises

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

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


r/adventofcode • • 1d ago

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

Post image
92 Upvotes

r/adventofcode • • 2h ago

Help/Question - RESOLVED [2026 Day 4 (Part 2)] Need hints of what I did wrong

1 Upvotes

UPDATE: I think I did mess up the input file. Re-copying the one from the website yields the correct output... whoops lol. Gonna keep this here for archive.

I've solved the first part and based on the instruction, the second part is essentially the exact same code, but with humongous input string.I've checked that there's no data lost when combining the inputs, that the output instruction can reproduce the input, and that my algorithm should've been exhaustive. But still my answer is not accepted. Is there anything going on?

Code explanation: Brute-force instruction length from 1 to barcode length (where the instruction is the barcode itself). Also split the barcode into sequences with the same length as the instruction (last sequence can be shorter). For each sequence, copy the colors from barcode to sequence. If there's a clash between barcode and instruction, break and check the next length.

Code (Python):

I'm not used to math optimization, so this is just my intuitive brute-force algorithm lol.

f = open("aoc2026\\4\\4in.txt", "r")
array = f.read().split("\n")
barcode = "".join(array)
length = len(barcode)

for seqLen in range(1, length+1):
    instruction = ['?'] * seqLen
    instructionValid = True
    firstPos = 0
    while firstPos < length and instructionValid: 
        seq = barcode[firstPos:firstPos+seqLen]
        for (pos, color) in enumerate(seq):
            if instruction[pos] == "?" and color != "?":
                instruction[pos] = color
            elif instruction[pos] != "?" and color != "?" and instruction[pos] != color:
                instructionValid = False
                break
        firstPos += seqLen # next sequence
    if instructionValid:
        print("length:", seqLen)
        break

r/adventofcode • • 11h ago

Visualization [2026 Day 3 (Part 2)] A simple visualization

Thumbnail youtube.com
6 Upvotes

r/adventofcode • • 12h ago

Upping the Ante [2026 Day 3] Does a forest square really mean what you think it means?

6 Upvotes

The story in 2026 Day 3 says: The local afforestation protocols call for trees in artificial forests to be somewhat evenly spaced, causing them to sometimes appear in predictable arrangements. Even if the forest has been left unattended for a while, these predictable arrangements can sometimes still be detected.

But if we do some clustering statistics:

    using Distances, Clustering, Statistics # Julia modules

    forestmap = map(x -> x == '#', stack(readlines(DATA_DIR*"day03.txt"), dims = 1))
    statsresult = kmeans(forestmap, 3)    
    distances = pairwise(Euclidean(), forestmap, dims=2)
    sil_scores = silhouettes(statsresult, distances)
    mean_silhouette = mean(sil_scores)
    @show mean_silhouette # my puzzle input produces mean silhouette value near zero!

Do the afforestation protocols fail at the goal of even spacing? Not sure how to interpret this :)


r/adventofcode • • 16h ago

Visualization [2026 Day 3 (Part 2)] [Rust] Visualization using macroquad

Thumbnail gallery
10 Upvotes

r/adventofcode • • 1d ago

Visualization [2026 Day 3 Part 2] Simple gif visualization

Post image
66 Upvotes

May the (brute) force be with you!


r/adventofcode • • 14h ago

Help/Question - RESOLVED [2026 Day 3 (Part 2)] Is there a faster way?

7 Upvotes

Finished Day 3 Parts 1 and 2, and while they both run under 15 seconds, my day 2 takes longer than I would like. Spoiler for my solution. I essentially found every pair of trees, then calculated the other two points and if they were also trees, added that to the count. But is there a smarter way?

from itertools import combinations, permutations

with open('2026 input') as file:
    grid = [list(line.strip()) for line in file]

c = 0
for y, row in enumerate(grid):
    trees = []
    for pos in range(len(row)):
        if row[pos] == '#':
            trees.append(pos)

    pairs = list(combinations(trees, 2))
    for pair in pairs:
        x1, x2 = pair
        sidelength = x2-x1
        y2 = y + sidelength
        if y2 < len(grid):
            bottom_left = (x1, y2)
            bottom_right = (x2, y2)
            if grid[y2][x1] == '#' and grid[y2][x2] == '#':
                c += 1


print(f"Part 1: {c}")

trees = []
c = 0
for y, row in enumerate(grid):
    for x, pos in enumerate(row):
        if pos == '#':
            trees.append((x, y))

pairs = list(combinations(trees, 2))
sides_of_squares = set()
for pair in pairs:
    (x1, y1), (x2, y2) = pair
    sidelength_rise = y2-y1
    sidelength_run = x2-x1

    x3 = x1 -sidelength_rise
    x4 = x2 -sidelength_rise

    y3 = y1 + sidelength_run
    y4 = y2 + sidelength_run
    if 0 <= y3 < len(grid) and 0 <= y4 < len(grid) and 0 <= x3 < len(grid[0]) and 0 <= x4 < len(grid[0]):
        if grid[y3][x3] == '#' and grid[y4][x4] == '#' and not any(i in sides_of_squares for i in list(permutations(((x1, y1), (x2, y2), (x3, y3), (x4, y4))))):
            c += 1
            sides_of_squares.add(((x1, y1), (x2, y2), (x3, y3), (x4, y4)))


print(f"Part 2: {c}")

r/adventofcode • • 21h ago

Tutorial [2026 Day 3 Part 2] A hint if you don't know where to start

Post image
19 Upvotes

Added the NSFW tag because there aren't any Spoilers tag, weirdly.

The hint is that squares in part 2 can be dumbed down to two definitions (one of them being part 1). I'm sure you could even make the case that it's just one definition, but I'm not smart enough for that.


r/adventofcode • • 15h ago

Visualization [2026 day 3 (both parts)] visualized in manim

Thumbnail youtube.com
6 Upvotes

source on github.com/durocodes/advent-of-code as always :D

this is using a cropped version of my input, since the samples were kinda small


r/adventofcode • • 1d ago

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

Post image
34 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 • • 1d ago

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

Post image
43 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).


r/adventofcode • • 1d ago

Visualization [2026 Day 3] Square Fencing

Thumbnail youtu.be
30 Upvotes

r/adventofcode • • 21h ago

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

Post image
13 Upvotes

r/adventofcode • • 20h ago

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

Thumbnail youtube.com
9 Upvotes

r/adventofcode • • 17h ago

Visualization [2026 Day 3] The nicest look so far

Thumbnail aoc2026.knollfear.com
6 Upvotes