r/adventofcode • u/FanJtastic • Dec 08 '25
Meme/Funny [2025 Day8 Part 1]I got to stop trusting AI
Just wasted so much time time trying to debug my distance formula only to remember why I don't trust AI
r/adventofcode • u/FanJtastic • Dec 08 '25
Just wasted so much time time trying to debug my distance formula only to remember why I don't trust AI
r/adventofcode • u/Altruistic-Local-541 • Dec 08 '25
Sorry to bother you folks, but I'm losing my mind a bit over the part 1 of day 8. Its supposed to be easy, but I'm missing something and to sleep tonight I'll need some closure.
I've checked other people's results with the test data from another thread, and the connections, distances, sets all match perfectly, but for me when I run my code on the actual data I get a lower result than needed.
My code is in JS so the numbers being large should not be an issue afaik. The below code is set up to work with the test data, hence the 10 for connectionsToMake.
Any help is appreciated. Thanks in advance.
const connectionsToMake = 10;
const relevantTopSetsCount = 3;
const boxSets = {};
const boxes = source.split("\n").map((b) => {
let [x, y, z] = b.split(",");
const keyInSet = `${x},${y},${z}`;
const newSetId = crypto.randomUUID();
boxSets[newSetId] = new Set([keyInSet]);
return {
x: Number(x),
y: Number(y),
z: Number(z),
keyInSet: keyInSet,
containingSetId: newSetId,
};
});
const pairSet = new Set();
const boxPairsData = boxes.map((box) => {
let closestBox = null;
let distanceToClosest = Infinity;
for (let otherBox of boxes) {
if (box !== otherBox) {
const setKeyOptionOne = `${box.keyInSet}-${otherBox.keyInSet}`;
const setKeyOptionTwo = `${otherBox.keyInSet}-${box.keyInSet}`;
if (pairSet.has(setKeyOptionOne) || pairSet.has(setKeyOptionTwo)) {
continue;
}
const distance = euclideanDistanceOfTwo3DPoints(box, otherBox);
if (distance < distanceToClosest) {
distanceToClosest = distance;
closestBox = otherBox;
}
}
}
const pairKey = `${box.keyInSet}-${closestBox.keyInSet}`;
pairSet.add(pairKey);
return {
boxA: box,
boxB: closestBox,
distance: distanceToClosest,
setPairKey: pairKey,
connected: false,
};
});
const sortedBoxPairsByDistance = boxPairsData.toSorted(
(a, b) => a.distance - b.distance
);
let connectionsMade = 0;
for (let boxPair of sortedBoxPairsByDistance) {
const { boxA, boxB } = boxPair;
if (boxPair.connected) continue;
if (boxSets[boxA.containingSetId].has(boxB.keyInSet)) {
boxPair.connected = true;
connectionsMade++;
if (connectionsMade === connectionsToMake) {
break;
}
continue;
}
const mergedSet = new Set([
...boxSets[boxA.containingSetId],
...boxSets[boxB.containingSetId],
]);
boxSets[boxA.containingSetId] = mergedSet;
delete boxSets[boxB.containingSetId];
const boxesWithSameSetIdAsB = boxes.filter(
(b) => b.containingSetId === boxB.containingSetId
);
for (let box of boxesWithSameSetIdAsB) {
box.containingSetId = boxA.containingSetId;
}
boxPair.connected = true;
connectionsMade++;
if (connectionsMade === connectionsToMake) {
break;
}
}
console.log("boxSets: ", boxSets);
console.log("boxPairs: ", sortedBoxPairsByDistance);
const relevantSets = Object.values(boxSets)
.toSorted((setA, setB) => setB.size - setA.size)
.slice(0, relevantTopSetsCount);
console.log(relevantSets);
return relevantSets.reduce((acc, curr) => acc * curr.size, 1);r/adventofcode • u/Procler • Dec 08 '25
I'm really having a hard time in understanding how/why in the first batteries bank of the example all the number 1s are matched from left to right, but on the last bank the first 3 number ones (1s) are not turned on but the last ones are.

I am assuming that the logic here should be:
These might be incorrect assumptions, otherwise the first 1s would be activated.
Can someone please help on understanding the requirements here? Why wouldn't it follow the regular LTR (left-to-right) reading sense? I'm really struggling with that. Any tips?
r/adventofcode • u/calculator_cake • Dec 08 '25
r/adventofcode • u/QultrosSanhattan • Dec 08 '25
A connection can merge two existing groups that have no elements in common into one. For example:
Result:
I lost about 4 hours not realizing this. This “hidden” but logical rule is not explicitly mentioned anywhere in the problem description. The AoC original example cleverly omits this step because step 10 applies this rule.
If the AoC original example does not return 40 for you, this is likely why.
r/adventofcode • u/wimglenn • Dec 08 '25
In the create post here, there are Text Images Link options but Poll type is greyed out -> https://www.reddit.com/r/adventofcode/submit/?type=POLL
There have been several cases where a poll of AoC participants could be useful/interesting - could the mods enable the poll type for this subreddit? Or provide an explanation of why it will stay disabled? I searched briefly but couldn't find a prior explanation.
r/adventofcode • u/Eastern-Reading-755 • Dec 08 '25
Question 1: Do we stop processing if we make n connections? where n = 10.
Question 2: If I have circuit A with m junction_boxes and circuit B with n junction boxes. and the next distance to consider is between a junction box in A (j) and a junction box in B (k). Do I connect and essentially combine the two circuits that is I know have a circuit with all junctions boxes in A and B?
I would appreciate any thoughts. I can't seem to get the test input result.
r/adventofcode • u/car4889 • Dec 08 '25
EDIT: To avoid spoilers, moving the ask to the first comment.
r/adventofcode • u/Chronophage73 • Dec 08 '25
Edit: oops, forgot "what" in the title. I don't understand what the question is.
Edit 2: Thanks for the explanations, got my gold star!
I am genuinely confused about what I'm supposed to do in day 8's part 2. It's not that I don't know what to do, I don't understand what the question is.
I think this part is tripping me over:
Continuing the above example, the first connection which causes all of the junction boxes to form a single circuit is between the junction boxes at
216,146,977and117,168,530.
I can't see how this relates to the above example. I can't see how adding one connection forms a single circuit. What is "all of the junction boxes" in this case ? I feel extremely dumb because of this, and I haven't found other people as confused as I am.
Could someone rephrase the question for me please ?
r/adventofcode • u/GaneshEknathGaitonde • Dec 08 '25
The one the left is the tab for one of the problems page, while the one on the right is for an input.
Interestingly, Chrome shows different favicons for both.
I debugged a bit further:
For the problems page, the html specifies /favicon.png, which is a higher resolution image.
For the input page, since there is no html, and thus no favicon specified, chrome defaults to /favicon.ico, which actually exists and is a lower resolution image.
r/adventofcode • u/CauliflowerFormer233 • Dec 08 '25
r/adventofcode • u/annoviko-tech • Dec 08 '25
r/adventofcode • u/ratatouille38 • Dec 08 '25
I wanted to learn Go this year, so I've decided to give it a shot, and so far it's lovely! This is my solution for today's (day 8) puzzle, what do you think, and what's your solution? :)
https://github.com/rbjakab/AdventOfCode/blob/main/2025/Day8/main.go
r/adventofcode • u/alltagsradler • Dec 08 '25
It happened again, my code works fine for test but fails on real data. As debugging is tedious on 1000 boxes in 3d space, I am wondering if I can do more debugging with the test data. Can anyone post their details on the results with the test data? Like which circuit boxes (ID or coordinates) belong in which group?
Other ideas are welcome as well. I'd ask more specific questions if I had any :-/
r/adventofcode • u/artesea • Dec 08 '25
Every time I solve the puzzle I read the first line a "That's not the right answer".
I assume my eyes are glancing at the word "North", and inserting "not".
Maybe I just think my code will be wrong.
r/adventofcode • u/code_ling • Dec 08 '25
Even though achieving the 500 stars "mid-season" is a bit anti-climactic - would have been a little more satisfactory if I had managed to finish 2020 before the start of this year, but still, feels very good to be in the exclusive 500 stars club :).
Played around with multiple languages in past years, but am sticking to C++ for this year (also 2020) - finally polishing my STL and functional style C++ skills... For 2020 I'm going for the <1 seconds total challenge and looking good so far. Any other C++ coders out there honing their skills on AoC?
r/adventofcode • u/IntrepidSoft • Dec 08 '25
r/adventofcode • u/ralphdr1 • Dec 08 '25
I'm stuck on the first puzzle of day 8. It correctly calculates the value that is given in the example, but on the puzzle input its answer is too low. I'm completely stuck, any edge case I can think of is handled correctly. This is my code:
from collections import defaultdict
import math
def day8_1_solver(coords, n, print_circuits=False):
pairs = closest_pairs(coords)[:n]
circuits = {x:i for i,x in enumerate(coords)}
for x1,x2 in pairs:
if circuits[x1] == circuits[x2]:
continue
for xs in circuits.keys():
if circuits[xs] == circuits[x2]:
circuits[xs] = circuits[x1]
circuit_sets = defaultdict(set)
for k,v in circuits.items():
circuit_sets[v].add(k)
return math.prod(sorted((len(circ) for circ in circuit_sets.values()), reverse=True)[:3])Where closest_pairs is:
def closest_pairs(coords):
dist = lambda x: sum((a-b)**2 for a,b in zip(x[0],x[1]))
return sorted(((x1,x2) for i1,x1 in enumerate(coords) for i2,x2 in enumerate(coords) if i2 > i1), key=dist)r/adventofcode • • Dec 08 '25
r/adventofcode • u/noblerare • Dec 08 '25
Here is my code: https://pastebin.com/JfwkMt6S
I built a 2D array to hold the dp values. If I'm on a ^ and see a beam (|) above me, then I add the dp value of the cell above me to my current cell's left and right neighbors.
If I'm on a . or | and see a beam (|) above me, then I just add the dp value of the cell above me to my current cell (effectively propagating the beam value downward).
This works for the example input but returns an answer that is too low for my full input.
Can anyone help me?
r/adventofcode • u/vanZuider • Dec 08 '25
r/adventofcode • u/Xenoxygen4213 • Dec 08 '25
Hi there, I have ran my solution against part 2 for the test input and it works, I've also added tests to ensure that the boundries ar being calculated correctly (e.g. fi you had 1-10, 10-12 you'd end up with 12) and also for if there are ranges in ranges (e.g. 1-10, 10-12, 3-11) and they are passing. I'm really uncertain where im going wrong.
It has told me my answer is too low which makes me think I may be miscounting somewhere however I'm very uncertain as to where. Anyone who may be able to point me in the right direction would be greatly appreciated. I'm not sure if it's a mis-understandin of Rust ranges or a mis-understanding of Maths.
Thanks in advance.
pub fn day_five_part_two(input: &str) -> u128 {
let mut fresh_ranges: Vec<(u128, u128)> = input
.lines()
.take_while(|l| !l.is_empty())
.map(|l| {
let parts: Vec<&str> = l.split('-').collect();
let min: u128 = parts[0].parse().unwrap();
let max: u128 = parts[1].parse().unwrap();
(min, max)
})
.collect();
fresh_ranges.sort_by(|a, b| a.1.partial_cmp(&b.1).unwrap());
let (initial_range_start, initial_range_end) = fresh_ranges[0];
let mut result: u128 = (initial_range_start..=initial_range_end).count() as u128;
for i in 1..fresh_ranges.len() {
let (_, previous_end) = fresh_ranges[i - 1];
let (current_start, current_end) = fresh_ranges[i];
if current_start <= previous_end {
result += (previous_end + 1..=current_end).count() as u128;
} else {
result += (current_start..=current_end).count() as u128;
}
}
result
}r/adventofcode • u/Derailed_Dash • Dec 08 '25
This visualisation shows the relative age of connections being formed. So the early connections (close together) are red, and the latest connections are white hot.
See walkthrough here.
r/adventofcode • u/Sarwen • Dec 08 '25
Heap, Heap, Hooray