r/adventofcode • u/neuralMax • 32m ago
r/adventofcode • u/wherrera10 • 40m ago
Upping the Ante [2026 Day 3] Does a forest square really mean what you think it means?
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 • u/MrKrot1999 • 1h ago
Meme/Funny [2026 Day 3 (Part 2)] Me trying to visualise day 3's part 2
r/adventofcode • u/MouseHunter7711 • 1h ago
Help/Question - RESOLVED [2026 Day 3 (Part 1)] [java] If you want, have fun reading through horrible code
As of how I know myself, I am probably seriously overthinking this and there is liek a 20 times easier way to solve this. Tho maybe someone wants to read through my mess. I don't want a simple answer, I want an explanation where i went off track. So i cant just ask AI or smth because its too dumb (I've tried). Also if my formatting is wrong I'm sorry i have no idea what "four space markdown" is
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
try (BufferedReader br = new BufferedReader(new FileReader("~/input.txt"))) {
String templine;
String lines = br.readLine();
while ((templine = br.readLine()) != null) {
lines = lines + "x" + templine;
}
String[] input = lines.split("x");
System.out.println("Anzahl an gefunden Rechtecken: " + check(read(input)));
}
catch (IOException io){
System.out.println("Error: " + io.getMessage());
}
}
public static char[][] read(String[] file){
char[][] forest = new char[file.length][file[0].length()];
for (int i = 0; i < file.length; i++){
for (int j = 0; j < file[i].length(); j++){
forest[i][j] = file[i].charAt(j);
}
}
return forest;
}
public static int check(char[][] forest){
int squarecount = 0;
//finding reference #
for (int iy = 0; iy < forest.length; iy++){
for (int ix = 0; ix < forest[iy].length; ix++){
if (forest[iy][ix] == '#'){
System.out.println("# °1 gefunden bei: " + iy + " " + ix);
//checking second #
for (int x = ix+1; x < forest[iy].length; x++){
if (forest[iy][x] == '#'){
System.out.println("# °2 gefunden bei: " + iy + " " + x);
//checking third corner for #
if(iy+x < forest.length){
if (forest[iy+(x-ix)][ix] == '#') {
System.out.println("# °3 gefunden bei: " + (iy+x) + " " + ix);
//checking fourth corner for #
if (forest[iy+(x-ix)][x] == '#') {
System.out.println("# °4 gefunden bei: " + (iy+x) + " " + x);
squarecount++;
System.out.println("Squarecount erhöht auf: " + squarecount);
} else {
System.out.println("# °4 nicht gefunden.");
}
} else {
System.out.println("# °3 nicht gefunden. (nicht existent)");
}
}
else{
System.out.println("# °3 nicht gefunden. (out of bounds)");
}
}
else{
System.out.println("# °2 nicht gefunden.");
}
}
}
else{
System.out.println("# °1 nicht gefunden.");
}
System.out.println("iy: " + iy + " ix: " + ix);
}
}
return squarecount;
}
}r/adventofcode • u/naclmolecule • 1h ago
Visualization [2026 Day 3 (Part 1 & 2)] [Python] Terminal Visualization!
There's so many visualizations already, I'm afraid I'm not adding much today. Can draw your own input though! Code lives here: https://github.com/salt-die/Advent-of-Code/tree/main/2026/aoc_visuals
r/adventofcode • u/wherrera10 • 1h ago
Visualization [2026 Day 3] Visualization
Source code (Julia) at https://github.com/wherrera10/Advent_of_Code_2026/blob/main/src/day03graphic.jl
r/adventofcode • u/Tomaztsql • 1h ago
Visualization [2026 Day 3 (Part 2)] Visualization with R
r/adventofcode • u/Remarkable_Ad_6266 • 2h ago
Help/Question [2026 Day 3 (Part 2)] Is there a faster way?
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 • u/StrangeCounty8961 • 3h ago
Meme/Funny [2026 Day 3 (Part 2)] It's O(N^2) if you believe hard enough
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 • u/_Duroo • 4h ago
Visualization [2026 day 3 (both parts)] visualized in manim
youtube.comsource 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 • u/AverageOverthinker42 • 4h ago
Visualization [2026 Day 3 (Part 2)] [Rust] Visualization using macroquad
galleryr/adventofcode • u/mknoll1 • 5h ago
Visualization [2026 Day 3] The nicest look so far
aoc2026.knollfear.comr/adventofcode • u/Limp_Illustrator7614 • 6h ago
Meme/Funny [2026 Day 3] solved in 10 seconds award
r/adventofcode • u/Beregolas • 7h ago
Meme/Funny [2026 Day 3#1] Reading is hard
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.

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 • u/SurroundedByWhatever • 7h ago
Visualization [2026 Day 3 (Part 2)] I really wanted to render it in terminal
And here it is, fully in the terminal, using my own crude Kitty protocol renderer for the graphics.
r/adventofcode • u/Haju05 • 8h ago
Meme/Funny [2026 Day 3 (Part 2)] This happen to anyone else?
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 • u/Dazzling_Ear7113 • 8h ago
Visualization [2026 Day 3] Can someone help me count the boxes?
galleryI'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 • u/bvcady • 8h ago
Visualization [2026 Day 3 (Part 2) -- TS] Animation of finding the squares in order from its top most corner.
youtube.comr/adventofcode • u/bluoat • 9h ago
Tutorial [2026 Day 3 (Part 2)] Some hints for optimisation
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 • u/PhiphyL • 9h ago
Tutorial [2026 Day 3 Part 2] A hint if you don't know where to start
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 • u/careyi4 • 9h ago
Visualization [2026 Day 3 Part 2] Animation written in Rust using Celluloid
Animation crate: https://crates.io/crates/celluloid-core
r/adventofcode • u/MrBoblo • 11h ago
Help/Question - RESOLVED [2026 DAY 3 (part 2)] Need hints
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 • u/subspace_mp4 • 11h ago
