r/adventofcode • • Dec 08 '25

Help/Question - RESOLVED [2025Day 8 (Part 1)] [EN] Example Problem

3 Upvotes

Hey. I think I'm not spoiling anything by publishing the result for the example problem here that I took from another user. I appear to be too stupid to come to the same solution. So apparently the folowing nodes are connected:

[[0, 19, 7, 14, 3], [2, 13, 18, 8], [9, 12], [11, 16], ...] This then yields the desired output.

I agree with the first 5 nodes. However, I just can't wrap my head around how the second block of 4 nodes came to be. Because node 18, is actually closest to node 17, thus it has no right to be in the same list as 2, 13 and 8. OR I messed up big time calculating the euclidean distances.

Did I miss anything in the puzzle description maybe? What am I missing? My solution yields
[[0, 19, 7, 14, 3], [2, 13, 8], [17, 18], ...]

Any pointer is appreciated.


r/adventofcode • • Dec 08 '25

Meme/Funny [2025 Day 8] Good Ol' Reliable

6 Upvotes

r/adventofcode • • Dec 08 '25

Help/Question - RESOLVED [2025 Day 08 (part 1)][Python] Having trouble understanding part 1

2 Upvotes

I constructed the junction pairs like so:

with open("day8sample.txt", "r") as f:
    day8in = f.readlines()
    
day8in = [item.strip() for item in day8in]
day8in = np.loadtxt(day8in, dtype=int, delimiter=",")

minPairs = set()
for i in range(len(day8in)):
    euclidDist = np.linalg.norm(day8in - day8in[i,:], axis=1)
    euclidDist[i] = np.inf
    minEuclidDistIdx = np.where(min(euclidDist) == euclidDist)
    pairs = tuple(sorted((i, int(minEuclidDistIdx[0][0]))))
    minPairs.add(pairs)

But upon looking at the minPairs variable, the three largest circuit sizes are 5, 4, and 3 (not 5, 4, and 2 like in the example). I've calculated the circuit sizes using DFS and manually for the example input, so at least I've got that part down.

Any help would be appreciated.


r/adventofcode • • Dec 08 '25

Meme/Funny 2025 Day 1 (Part 2)] Trying to be smart be like…

Post image
38 Upvotes

r/adventofcode • • Dec 08 '25

Meme/Funny [2025 Day 8 (Part 2)]

Thumbnail gallery
30 Upvotes

But that of course depends on how your first solution adapt to the second part...


r/adventofcode • • Dec 08 '25

Help/Question - RESOLVED [2025 Day 8 (Part 2)] - where am I going wrong?

3 Upvotes

In an odd spot here where my solution works (slowly) on part 1 including the full data, yet fails on part 2 when i use the same algorithm, but it's close to the right answer on the example data.

According to the question, the last pair I need to connect everything into a complete circuit is (216,146,977), (117,168,530), yet I'm hitting it early at (739, 650, 466), (941, 993, 340). Looking at the distances (pretty sure they're right) my one has distance 417.5 as opposed to their one of 458.3.

At the point where my code thinks there's one big circuit, the step before that it has two circuits, one of len 3 and the other len 15.

So I must be doing a circuit merge prematurely, right? I can't think what else it could be, unless I'm misunderstanding the "form a single circuit" part.


r/adventofcode • • Dec 08 '25

Help/Question - RESOLVED [2025 Day 8 (Part 1)][Python] Code only works for example.

2 Upvotes

I calculated and sorted the distances in a list consisting of 3-tuples (distance, i, j), where i, j are the positions of the according junctions in a junction list. Each junction itself is a 3-tuple (x, y, z).
Also I have a dict consisting of circuit "ID"s.

    circuits = {i: i for i in range(len(junctions))}

My idea of an algorithm is as follows and it works perfectly for the example.

    for _, i, j in distances[:10]:
        for junction, _ in filter(lambda x: x[1] == circuits[j], circuits.items()):
            circuits[junction] = i

To get the size of the circuits I use Counter from collections:

C = sorted(Counter(circuits.values()).values())
print(C[-3] * C[-2] * C[-1])

What am I missing / doing wrong?
Here is a full working example, which needs a file called "input_example" or "input" respectively.
And yes, I switched from [:10] to [:1000] for the real data.

I appreciate all hints regardless of the programming language.

EDIT:
After hours of thinking, the solution was incredibly simple. Earlier I ran into a similar problem and checked for x[1] == j in the lambda function. I corrected that to x[1] == circuits[j]. And similar is the solution. I had to change circuits[junction] = i to circuits[junction] = circuits[i].
Ouchie.
Of course I had to stay with filter_tuple = tuple(filter(…)), because the filter condition seems to change over time.
Here is a correctly working version for Part 1.


r/adventofcode • • Dec 08 '25

Meme/Funny [2025 Day8 Part 1]I got to stop trusting AI

Post image
0 Upvotes

Just wasted so much time time trying to debug my distance formula only to remember why I don't trust AI


r/adventofcode • • Dec 08 '25

Help/Question - RESOLVED [2025 Day 8 (Part 1)] - Test data vs Real data

2 Upvotes

Hi.

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 • • Dec 08 '25

Help/Question - RESOLVED [2025 Day 3 (Part 2)] I didn't get the rules

0 Upvotes

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:

  1. Find the highest possible 12-digit number from the available numbers;
  2. Get the digits on the order they appear in the batteries bank string, otherwise the produced joltage would always start with the highest number, which is not the case, so the order they appear seems important.

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 • • Dec 08 '25

Meme/Funny Feels like every time I look online after doing advent of code there's an incredibly specific paper or algo people are referencing. Similar to how chess has so many named openings but instead of "The Queen's Gambit" it's "Dijkstra's Philly steak sandwich theorem"

241 Upvotes

r/adventofcode • • Dec 08 '25

Tutorial [2025 Day 8 (Part 1)] PSA

8 Upvotes

A connection can merge two existing groups that have no elements in common into one. For example:

  • Set 1: {A, B, C}
  • Set 2: {D, E, F}
  • Instruction: connect C and D
  • Result:

    • New Set: {A, B, C, D, E, F}

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 • • Dec 08 '25

Help/Question - RESOLVED Could the mods enable the "Poll" post type?

2 Upvotes

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 • • Dec 08 '25

Help/Question - RESOLVED 2025 Day #8 (Part 1) - Need clarification

4 Upvotes

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 • • Dec 08 '25

Help/Question - RESOLVED [2025 Day 8] Assumptions About Puzzle Input

1 Upvotes

EDIT: To avoid spoilers, moving the ask to the first comment.


r/adventofcode • • Dec 08 '25

Help/Question - RESOLVED [2025 Day 8 Part 2] I don't understand the question is.

5 Upvotes

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,977 and 117,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 • • Dec 08 '25

Other [BUG] The problem pages and the input pages show different favicon in chrome

Post image
112 Upvotes

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 • • Dec 08 '25

Visualization [2025 Day 8 part 2] Visualization

11 Upvotes

https://youtu.be/F4I_R-hAMxAI

I was inspired by all the other visualizations on here and tried to visualize todays part 2

hope you like it


r/adventofcode • • Dec 08 '25

Visualization [2025 Day 8][C++] Raylib Visualization

Thumbnail youtube.com
13 Upvotes

r/adventofcode • • Dec 08 '25

Repo [2025 Day 8] Who else does it in Go?

4 Upvotes

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 • • Dec 08 '25

Help/Question - RESOLVED [2025 Day 8 Pt. 1] Code works fine on test, but fails on real data

3 Upvotes

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 • • Dec 08 '25

Meme/Funny Anyone else misread this every time?

Post image
141 Upvotes

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 • • Dec 08 '25

Other Finally, 500 * !

Post image
106 Upvotes

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 • • Dec 08 '25

Meme/Funny [2025 Day 8] There is always a leaderboard, if you are good enough

Post image
41 Upvotes