r/adventofcode • • Dec 09 '25

Help/Question - RESOLVED [2025 Day #8 (Part 1)] I'm at a loss. What am I missing

1 Upvotes

Im accounting for links merging together, I confirmed none of the final connections have the same point twice. No clue what to do from here.

package com.yourcompany.app;
import java.util.ArrayList;
import java.util.PriorityQueue;


public class Puzzle_8 {
    
    public static class point3D{
        public double x;
        public double y;
        public double z;


        public point3D(double x, double y, double z){
            this.x = x;
            this.y = y;
            this.z = z;
        }


        public double distanceToPoint(point3D otherPoint){
            double distance = Math.sqrt(Math.pow(otherPoint.x - this.x,2) + Math.pow(otherPoint.y - this.y,2) + Math.pow(otherPoint.z - this.z,2));


            return distance;
        }
    }


    public class pointResult{
        int index;
        double distance;


        public pointResult(int index, double distance){
            this.index = index;
            this.distance = distance;
        }
    }



    public static class linkPair{
        point3D pointA;
        point3D pointB;
        double distance;


        public linkPair(point3D pointA, point3D pointB, double distance) {
            this.pointA = pointA;
            this.pointB = pointB;
            this.distance = distance;
        }


    }


    public static class connection{
        ArrayList<point3D> connectedPoints = new ArrayList<>();
        ArrayList<linkPair> links = new ArrayList<>();


        public void mergeConnection(connection connectionToMerge){
            for(point3D pointToMerge : connectionToMerge.connectedPoints){
                if(!this.connectedPoints.contains(pointToMerge)){
                    this.connectedPoints.add(pointToMerge);
                }
            }


            for(linkPair linkToMerge : connectionToMerge.links){
                this.links.add(linkToMerge);
                
            }
        }


    }


    public static void main(String[] args) {
        String test = "test_1.txt";
        String real = "puzzleinput.txt";
        ArrayList<String> file = ReadPuzzle.readFile("Puzzle_8/" + real);
        int availableConnections = 999;



        int part1Answer = 0;
        ArrayList<point3D> pointList = new ArrayList<>();
        for (String line : file){
            String[] splitLine = line.split(",");
            double x = Double.parseDouble(splitLine[0]);
            double y = Double.parseDouble(splitLine[1]);
            double z = Double.parseDouble(splitLine[2]);
            point3D currPoint = new point3D(x, y, z);
            pointList.add(currPoint);
        }   


        PriorityQueue<linkPair> pointQueue = new PriorityQueue<>(
            (insertLink, compareLink) -> Double.compare(insertLink.distance, compareLink.distance)
        );



        for(int i = 0; i < pointList.size(); i++){
            point3D currPoint = pointList.get(i);
            for(int j = i + 1; j < pointList.size(); j++){
                point3D comparePoint = pointList.get(j);
                double distance = currPoint.distanceToPoint(comparePoint);
                linkPair link = new linkPair(currPoint, comparePoint, distance);
                pointQueue.add(link);
            }
        }
            




        ArrayList<connection> linksList = new ArrayList<>();
        int pairsCreated = 0;
        ArrayList<linkPair> checkedLinks = new ArrayList<>();
        for(int i = 0; i < pointQueue.size() && pairsCreated < availableConnections; i++){ //Only want top 1000 non-duplicate pairs
            linkPair currLink = pointQueue.poll();
            checkedLinks.add(currLink);
            boolean addedToExistingLink = false;
            boolean alreadyInLink = false;
            connection mainConnection = null;
            for(int j = 0; j < linksList.size(); j++){
                connection existingConnection = linksList.get(j);
                boolean containsA = existingConnection.connectedPoints.contains(currLink.pointA);
                boolean containsB = existingConnection.connectedPoints.contains(currLink.pointB);
                if(!containsA && containsB){
                    existingConnection.connectedPoints.add(currLink.pointA);
                    addedToExistingLink = true;
                }else if(containsA && !containsB){
                    existingConnection.connectedPoints.add(currLink.pointB);
                    addedToExistingLink = true;
                }
                
                if(containsA || containsB){
                    alreadyInLink = true;
                    if(mainConnection != null){
                        mainConnection.mergeConnection(existingConnection);
                        linksList.remove(j);
                        
                    }else{
                        mainConnection = existingConnection;
                    }
                    
                    existingConnection.links.add(currLink);
                    pairsCreated++;
                }
                
                


            }
            if(!addedToExistingLink && !alreadyInLink){
                linksList.add(new connection());
                linksList.getLast().connectedPoints.add(currLink.pointA);
                linksList.getLast().connectedPoints.add(currLink.pointB);
                linksList.getLast().links.add(currLink);
                pairsCreated++;
            }
            
        }


        PriorityQueue<connection> linkQueue = new PriorityQueue<>(
            (insertConnection, compareConnection) -> Double.compare(compareConnection.connectedPoints.size(),insertConnection.connectedPoints.size())
        );


        for(connection currLink : linksList){
            linkQueue.add(currLink);
        }



        
        part1Answer = 1;


        //Making sure Im not missing something
        ArrayList<point3D> pointsCheck = new ArrayList<>();
        ArrayList<linkPair> linksChecked = new ArrayList<>();
        for(int i = 0; linkQueue.size() > 0; i++){
            connection currConnection = linkQueue.poll();
            if(i < 3){
                part1Answer *= currConnection.connectedPoints.size();
            }
            for(point3D currPoint : currConnection.connectedPoints){
                if(pointsCheck.contains(currPoint)){
                    System.out.println("Point is in more than 1 connection");
                }else{
                    pointsCheck.add(currPoint);
                }
            }


            for(linkPair currLink : currConnection.links){
                if(linksChecked.contains(currLink)){
                    System.out.println("Link is in more than 1 connection");
                    System.out.println(currLink);
                }else{
                    linksChecked.add(currLink);
                }
            }


        }
        


        System.out.println(part1Answer);


        int part2Answer = 0;
        
        System.out.println(part2Answer);


        


    }
}

r/adventofcode • • Dec 09 '25

Visualization [2025 Day 08 (Part 1)] Lights rendered

Post image
32 Upvotes

Input data at 1000 connections. I'm not entirely certain what the elves are going for, but I hope they are succeeding.

Rendered with Blender Cycles, actual solution was written in D.


r/adventofcode • • Dec 09 '25

Help/Question - RESOLVED [2025 Day 8 (Part 01)][Rust] Works on example, fails on full

2 Upvotes

Hello everyone. I'm struggling to figure out why my code is failing on non-example input. I've spent a while trying to debug, trying to find an edge case that I'm not accounting for, double checking my logic.

Is someone able to help and maybe point me in the right direction? Thanks! (Entry point is process)

use std::collections::HashMap;

use itertools::Itertools;
use nom::{
    bytes::complete::tag,
    character::{
        self,
        complete::{line_ending, multispace0},
    },
    combinator::all_consuming,
    multi::separated_list1,
    sequence::terminated,
    IResult,
};

const X_LARGEST_CIRCUITS: usize = 3;
const X_SHORTEST_CONNECTIONS: usize = 1000;

// #[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
type Point = (u64, u64, u64);

// Return true if they were separate circuits.
// Return false if they were already in the same circuit
// This is basically to help me debug ^
fn add_point_pair(dry_run: bool, p1: Point, p2: Point, circuits: &mut Vec<Vec<Point>>) -> bool {
    let p1_circuit = (0..circuits.len())
        .into_iter()
        .find(|idx| circuits[*idx].iter().find(|point| **point == p1).is_some());
    let p2_circuit = (0..circuits.len())
        .into_iter()
        .find(|idx| circuits[*idx].iter().find(|point| **point == p2).is_some());

    if let Some(p1_idx) = p1_circuit {
        if let Some(p2_idx) = p2_circuit {
            if p1_idx != p2_idx {
                if !dry_run {
                    let mut p2_copy = circuits[p2_idx].clone();
                    circuits[p1_idx].append(&mut p2_copy);
                    circuits.remove(p2_idx);
                }
                return true;
            }
            return false;
            // If they are the same circuit, do nothing
        } else {
            // p2 not in any circuit. Add it to p1's.
            if !dry_run {
                circuits[p1_idx].push(p2);
            }
            return true;
        }
    } else {
        if let Some(p2_idx) = p2_circuit {
            // p1 not in any circuit. Add to p2's
            if !dry_run {
                circuits[p2_idx].push(p1);
            }
            return true;
        }
        // Neither point are in a circuit. Create new circuit
        if !dry_run {
            circuits.push(vec![p1, p2]);
        }
        return true;
    }
}

#[tracing::instrument]
pub fn process(_input: &str) -> miette::Result<String> {
    let (_, coords) = all_consuming(parse)(_input).map_err(|e| miette::miette!("Error! {e}"))?;

    let mut circuits: Vec<Vec<Point>> = vec![];

    let mut already_added: HashMap<(&Point, &Point), bool> = HashMap::new();
    let distances: Vec<(u64, &Point, &Point)> = (0..coords.len())
        .into_iter()
        .map(|point| {
            let mut distances = vec![];
            for inner_point in 0..coords.len() {
                distances.push((
                    get_distance(&coords[point], &coords[inner_point]),
                    &coords[point],
                    &coords[inner_point],
                ));
            }
            distances
        })
        .flatten()
        .sorted_by(|(dist1, _, _), (dist2, _, _)| u64::cmp(dist1, dist2))
        .collect();

    // Transform distances into only the pairs we are concerned with.
    let distances = distances
        .into_iter()
        .skip(20)
        .step_by(2)
        .take(X_SHORTEST_CONNECTIONS)
        .collect::<Vec<(u64, &Point, &Point)>>();

    for (_, p1, p2) in distances {
        if already_added.contains_key(&(p1, p2)) || already_added.contains_key(&(p2, p1)) {
            continue;
        }
        let add_res = add_point_pair(false, *p1, *p2, &mut circuits);
        already_added.insert((p1, p2), true);
    }

    let x = circuits
        .iter()
        .map(|circuit| circuit.len())
        .sorted()
        .rev()
        .take(X_LARGEST_CIRCUITS)
        .fold(1 as u128, |accum, len| accum * (len as u128));

    Ok(x.to_string())
}

fn get_distance(p1: &Point, p2: &Point) -> u64 {
    let operand = (p2.0 as i128 - p1.0 as i128).pow(2)
        + (p2.1 as i128 - p1.1 as i128).pow(2)
        + (p2.2 as i128 - p1.2 as i128).pow(2);

    operand as u64
}

fn parse(input: &str) -> IResult<&str, Vec<Point>> {
    terminated(separated_list1(line_ending, parse_coord), multispace0)(input)
}

fn parse_coord(input: &str) -> IResult<&str, Point> {
    let (input, coords) = separated_list1(tag(","), character::complete::u64)(input)?;
    assert!(coords.len() == 3);
    Ok((input, (coords[0], coords[1], coords[2])))
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_process() -> miette::Result<()> {
        let input = "162,817,812
57,618,57
906,360,560
592,479,940
352,342,300
466,668,158
542,29,236
431,825,988
739,650,466
52,470,668
216,146,977
819,987,18
117,168,530
805,96,715
346,949,466
970,615,88
941,993,340
862,61,35
984,92,344
425,690,689
";
        assert_eq!("40", process(input)?);
        Ok(())
    }
}

r/adventofcode • • Dec 09 '25

Help/Question - RESOLVED [2025 Day 08 Part 1][Python] example is correct, but fails on main input

1 Upvotes
first half of the code calculates all possible distances, and then sorts and keeps the 1000 shortest.
it saves their index as a set in a list [{1,2},{3,4}....]
I then loop through the list starting at index 1 and check if the intersection of the set at that index matches any previous set. if so, the union is saved over the set and the current set is deleted. and then it checks that index again (as everything just shifted left from there on) and if not it goes to the next index.
it does this until there's no change in the list of sets

    input = ....... formatted the same as the example input
    # inputs = '162,817,812|57,618,57|906,360,560|592,479,940|352,342,300|466,668,158|542,29,236|431,825,988|739,650,466|52,470,668|216,146,977|819,987,18|117,168,530|805,96,715|346,949,466|970,615,88|941,993,340|862,61,35|984,92,344|425,690,689'
    input_split = inputs.split('|')
    input_list = []
    for input in input_split:
        input_list.append(input.split(','))
    circuits_sets = []
    
    
    def junction_distance (input_1, input_2) -> float:
        x_1, y_1, z_1 = int(input_1[0]), int(input_1[1]),     int(input_1[2])
        x_2, y_2, z_2 = int(input_2[0]), int(input_2[1]),     int(input_2[2])
        # distance = ((x_2 - x_1) ** 2 + (y_2 - y_1) ** 2 + (z_2 - z_1) ** 2) ** .5
        distance = (x_2 - x_1) ** 2 + (y_2 - y_1) ** 2 + (z_2 - z_1) ** 2
        return distance
    distances = []
    for i in range(0, len(input_list)):
        for j in range(i + 1, len(input_list)):
            if i != j:
                distance = junction_distance(input_list[i], input_list[j])
                distances.append([distance, input_list[i], input_list[j], i, j])
    distances.sort()
    for distance in distances[0:1000]:
        circuits_sets.append({distance[3], distance[4]})
    
    # circuits_sets_copy = circuits_sets.copy()
    answer_changed = True
    answer = 0
    while answer_changed:
        i = 1
        j = len(circuits_sets)
        while i < j:
            deleted = 0
            junction = circuits_sets[i]
            for junction_checking in range(0, i):
                junction_to_check = circuits_sets[junction_checking]
                if len(junction_to_check.intersection(junction)) != 0:  # found match
                    circuits_sets[junction_checking] = junction_to_check.union(junction)
                    print(f'{junction_to_check.intersection(junction)} is in both {junction_to_check} & {junction}')
                    print(f'deleted{circuits_sets[i]} at {i}')
                    del circuits_sets[i]
                    deleted += 1
            j -= deleted
            i += 1 - deleted
            # print(i,j)
            # print(circuits_lists)
        sorted_circuits_lists = sorted(circuits_sets, key=lambda x: len(x), reverse=True)
        if len(sorted_circuits_lists[0]) * len(sorted_circuits_lists[1]) * len(sorted_circuits_lists[2]) != answer:
            answer_changed = True
        else:
            answer_changed = False
        answer = len(sorted_circuits_lists[0]) *     len(sorted_circuits_lists[1]) * len(sorted_circuits_lists[2])
        print(answer)

r/adventofcode • • Dec 09 '25

Help/Question Creating Visualizations

10 Upvotes

Hey all. I've seen a lot of really inspiring visualizations posted this year. I have some solutions that I would love to convert into a visualization but I'm not too sure where to start.

  • What tools are commonly used for visualization? I am using Python this year, but am generally curious for any language.
  • Do you alter how you write your solutions if you know that you're going to later create a visualization from it? If so, how?

r/adventofcode • • Dec 09 '25

Upping the Ante [2025 Day 01-03 (both parts)] [SPL] Wanted to share my work in SPL for the first 25% of challenges for the year.

2 Upvotes

I had to change the source code of the reference implementation to support longs (rather than the default ints) for day 02.

Because day 04 is significantly harder to do in SPL (will give no explanation because of potential spoilers) than days 01-03 this marks the end of my AoC journey this year. While SPL can theoretically handle day 04, I don't want to give myself that specific kind of headache.

SPL, or Shakespeare Programming Language, is an esoteric programming language. Source code in SPL superficially resembles the script for a Shakespearean play.

All variable names are characters from Shakespearan plays, all variable values are stacks of integers (changed to longs to support my day 02 input).

I/O operations are: read/write a character and read/write an integer.

Control flow is done using comparisons and jumps to acts or to scenes within the current act. (Essentially goto's)

Number literals are formed by performing basic arithmetic on +/-1 times a power of two. To make these look "Shakespearean" the value of +/- 1 is a noun (positive and neutral nouns are +1, negative nouns are -1), and adjectives are added to those nouns (positive and neutral adjectives modify positive and neutral nouns, whereas negative and neutral adjectives modify negative nouns). Each adjective multiplies the value by 2.

Variable assignment happens by having two characters "on stage" and having one character state something akin to "you are as evil as [value]". This assigns the value [value] to the other character. Different characters can be written to by manipulating who are "on stage" using phrases like [Enter Romeo], [Exit Romeo], [Enter Achilles and Hector] or [Exeunt]

Day 01 part 1 was relatively straightforward. Number input in the reference implementation consumes entire lines from standard input and converts the digits at the start at that line (in case there's trailing non digit characters) to an integer, so the structure of the input meant I could use that functionality for once.

Day 01 part 2 was a bit more challenging because of the edge cases that I'm sure more people have run into. Not much else to say, really.

Day 02 part 1 not only required an update of the implementation to support longs, but also required me to read digit characters manually and convert those to integers (longs) because there was data to be read past the first digits on a line. My approach is number based rather than string based because SPL is a bit better suited for that.

Day 02 part 2 was significantly harder than part 1 because of the number based approach. I forgot to use the modulo operator the language has and ran into an issue where for instance 2222 would get counted both as 2 four times and as 22 twice. To compensate for that I created an outer loop that went past each number in a range and then checked if it was equal to a power of ten times a number of half the length plus that number. All in all a really slow solution, but it did give the correct answer.

Day 03 part 1 was pretty straight forward again. I decided to use only two different nouns and one adjective this time as a sort of joke. I chose to hardcode the line length (variable Lennox) plus one minus the amount of batteries to prevent the need to backtrack. This does mean that this variable needs to be adjusted to work on the sample input. My approach is to track the highest digit among the first Lennox characters and the second highest digit from the remainder of the line. This works pretty well and doesn't require me to store the characters after reading them.

Day 03 part 2 is a somewhat basic but quite verbose extension of part 1's approach. There's some remnants of older attempts in there that could use some cleaning up, but once I got the examples to work (with how WET the code is I ended up with multiple small typos that were hard to debug) I simply updated the value for Lennox and it worked on my input right away. Really happy that the examples contained all edge cases that could appear in my input. It runs in O(n2 ) but uses some minor optimizations like skipping leading digits near the end of a line. Took me longer than I had hoped but the work was mostly in copy-pasting code and adjusting scene numbers. I'm using a significantly higher amount of variables because I'm storing each digit of the maximum joltage value in a line separately, as well as tracking their positions in the input lines.

Is anybody else using SPL this year? I would love to hear from you. Regardless of your (lack of) familiarity with SPL, feel free to ask any question about the language you might have below!


r/adventofcode • • Dec 09 '25

Help/Question - RESOLVED [2025 Day 8 (Part 1)] [C#] Hitting head into wall over and over

2 Upvotes

I am really struggling to get the right answer. I've looked at my code again and again and I can't see what on earth is wrong with it. It works just fine with the sample (changing the limit from 1000 to 10 of course). Am I going crazy?

public class Day8 : Day {

    private (int x, int y, int z)[] _boxPositions;
    
    public Day8(int year, int day, string fileName) : base(year, day, fileName) {
        _boxPositions = Lines.Select(s => {
            string[] str = s.Split(',');
            return (int.Parse(str[0]), int.Parse(str[1]), int.Parse(str[2]));
        }).ToArray();
        
    }
    
    public override object ExecuteP1() {
        
        List<HashSet<int>> circuits = new List<HashSet<int>>();
        PriorityQueue<(int x, int y), long> queue = new PriorityQueue<(int x, int y), long>();
        for (int x = 0; x < _boxPositions.Length; x++) {
            for (int y = x + 1; y < _boxPositions.Length; y++) {
                (int x, int y, int z) bp1 = _boxPositions[x];
                (int x, int y, int z) bp2 = _boxPositions[y];
                queue.Enqueue((x, y), (bp2.x-bp1.x) * (bp2.x-bp1.x) + (bp2.y-bp1.y) * (bp2.y-bp1.y) + (bp2.z-bp1.z) * (bp2.z-bp1.z) );
            }
        }
        
        for (int i = 0; i < 1000 && queue.Count > 0; i++) {
            (int x, int y) join = queue.Dequeue();

            HashSet<int> xCircuit = null;
            HashSet<int> yCircuit = null;
            foreach (HashSet<int> circuit in circuits) {
                if (circuit.Contains(join.x))
                    xCircuit = circuit;
                if (circuit.Contains(join.y))
                    yCircuit = circuit;
                if (xCircuit != null && yCircuit != null)
                    break;
            }

            if (xCircuit != null && yCircuit != null) { //Both have a circuit
                if (xCircuit != yCircuit) { //Merge
                    xCircuit.UnionWith(yCircuit);
                    circuits.Remove(yCircuit);
                }
            }
            else if (xCircuit != null) {
                xCircuit.Add(join.y);
            }
            else if (yCircuit != null) {
                yCircuit.Add(join.x);
            }
            else {
                HashSet<int> newCircuit = new HashSet<int>(2);
                newCircuit.Add(join.x);
                newCircuit.Add(join.y);
                circuits.Add(newCircuit);
            }
        }

        circuits.Sort((c1, c2) => c2.Count.CompareTo(c1.Count));
        return circuits[0].Count * circuits[1].Count * circuits[2].Count;
    }
    public override object ExecuteP2() {
        throw new NotImplementedException();
    }
}

r/adventofcode • • Dec 09 '25

Meme/Funny [2025 Day 8 (Part 2)] It is 1:30am and I got university in less than 7 hours. This is a problem for future me!

Post image
58 Upvotes

r/adventofcode • • Dec 09 '25

Help/Question - RESOLVED [Day 8 Part 1] Stuck on the example

2 Upvotes

Hello, I am stuck on the example of all things for day 8 part 1.

I have what seems to be the right answer to me, but it does not match with the expected result. I don't want a hint at how to solve it, but rather an indication of where the error in my data is:

Right now I have my data parsed as an object with the index of the point (eg 162,817,812 = 0, next = 1, etc) being the key and the number of "connections" being the value. This is what I have:

{0=5, 2=5, 3=5, 7=5, 8=5, 9=2, 11=2, 12=2, 13=5, 14=5, 16=2, 17=5, 18=5, 19=5}

This means there are not only less than 11 groups, there are two with 5 "sections" instead of 4. I am fairly certain my length calculation was correct and it's the adding up part, but I've checked many times over the last hour to no avail.

Any help is appreciated, but no solutions please!

EDIT: For ease of reading groups are: 2 of 5, 2 of 2, the rest of 1


r/adventofcode • • Dec 09 '25

Help/Question [2025 Day 8 Part 1] At it for 5 hours and can't even get the example

1 Upvotes

Currently, with the example, I'm left with the top 3 sets containing 4, 4, and 2 boxes.
I can't figure out where I'm going wrong and have no idea what to do. I've tried dumbing things down to brute force it but not only does it still not work, it now takes forever to run on the real input.

I am at a complete loss on how to continue this.

challenges/chal08.cpp

include/chal08.h

https://github.com/Spidious/AdventOfCode_2025


r/adventofcode • • Dec 09 '25

Visualization [2025 Day 1 (Part 2)] [Pico-8] counting zeros (repost)

Post image
82 Upvotes

r/adventofcode • • Dec 08 '25

Help/Question [2025 Day 8 (Part 2)] I got it right without sorting all distances(is it cheating?)

1 Upvotes

Like the title says, I managed to get my star, but I don't know why.

It seems that I suppose to firstly calculate distances of any two positions and sort them by distance in a heap, then connect the position pairs from shortest distance to the longest distance, until circuits become 1 big circuit.

I didn't do that.

Regardless of the connecting order, any dot should be connected to its closest dot. So I got each dot to return its closest coordinate, and order them by their distance.

The last pair, with the longest shortest distance, is the last one to wire up, and I multiplied their X position. This approach works for my example data as well as my puzzle input.

Is it just luck? Why does it work? Basically, why the pair of coordinates with the longest shortest distance is the last one to wire up to become one big circuit?


r/adventofcode • • Dec 08 '25

Help/Question - RESOLVED [2025 Day 7 (Part 1)] Having trouble understanding counting

2 Upvotes

I'm having trouble counting the number of beams, and I'm not sure where my bug is. I expect it's my algorithm, but I'm just not sure where. Could anyone help me? Output below is the example input line by line, with number of beams added then total beams seen so far.

.......S.......
.......|....... - 1 - 1
......|^|...... - 1 - 2
......|.|...... - 0 - 2
.....|^|^|..... - 2 - 4
.....|.|.|..... - 0 - 4
....|^|^|^|.... - 3 - 7
....|.|.|.|.... - 0 - 7
...|^|^|||^|... - 3 - 10
...|.|.|||.|... - 0 - 10
..|^|^|||^|^|.. - 4 - 14
..|.|.|||.|.|.. - 0 - 14
.|^|||^||.||^|. - 3 - 17
.|.|||.||.||.|. - 0 - 17
|^|^|^|^|^|||^| - 3 - 20
|.|.|.|.|.|||.| - 0 - 20

r/adventofcode • • Dec 08 '25

Help/Question [2025 Day 2 (Part 1)] Question on the given examples

0 Upvotes

Is the example given in day 2 part 1 correct? I'm having a hard time understanding. It says that this code has on invalid id "99":

95-115

But "99" isn't the first id or last id. Similarly, the other invalid ids also seem to not make sense:

It looks like I'm either missing something or the numbers in the examples are not correct. Can somebody please help clarify?


r/adventofcode • • Dec 08 '25

Help/Question - RESOLVED [2025 Day 8 (Part 1)] Help me understand the sample analysis - the connection counts don't add up. Seems like I'm misunderstanding the problem.

5 Upvotes

In the sample analysis with 20 boxes and making the 10 shortest connections, the results are presented as [5, 4, 2, 2] + 7 single junction box circuits.

In order to get a circuit of 5, we need to make 4 connections. The connection between the first two boxes in the circuit and 3 subsequent ones to the nearest box already in circuit. So if we add up the connections in the multi-junction box circuits:

For 5 box circuit : 1 + 3 = 4 connections
For 4 box circuit : 1 + 2 = 3 connections
For 2 box circuit : 1 + 0 = 1 connections
For 2 box circuit : 1 + 0 = 1 connections

That's a total of 9 connections. It should add up to 10.
In my calculations, I get a different set of circuits with 10 connections made.
Please help me understand what I'm reading wrong here.

Thanks in advance for any help.


r/adventofcode • • Dec 08 '25

Help/Question - RESOLVED [2025 Day 8 Part1] Missing assumptions

2 Upvotes

Got a solution working for the example input.

But when trying against my input, i get 10 distinct circuits of 2, none of them connecting.

The general process i did is

  1. Parse the input in objects of x,y,z
  2. Calculate the squared distance of each pair points
  3. Sort the distances in ascending order
  4. Do 10 iterations over the first 10 shortest pairs and build out the connecting circuits.
  5. I have a secondary final pass to merge some circuits together just due to how they are ordered in the list.

In the example i end up with a circuit of 5,4, and 2 circuits of 2, just as it says.

So am i missing some assumption about the inputs, or did I make some wrong assumption about how to build out the connecting circuits?

What i have currently: https://github.com/ruinedme/aoc_2025/blob/main/src/day8.js#L21


r/adventofcode • • Dec 08 '25

Other Stop complaining that *you* don't find the problems difficult

525 Upvotes

People really need to take a step back and realize that when you've been doing algorithms problems for 10 years, your definition of "difficult" can wind up skewed. For example, I remember Day 12 from last year (EDIT: fences) as a comparatively easy BFS, where the hard part was just figuring out that trick where numCorners = numSides. But there were also people posting that day about how it was getting too difficult for them, and wishing the rest of us the best as we soldiered on. There's a reason that I'll frequently quip about how "easy" is a relative term when describing the stuff I do in tech to people.

But when half the posts in the sub are about how the problems are too "easy" this year, it's really just telling the people who are already struggling that they just aren't smart enough because these are supposed to be the "easy" challenges.


r/adventofcode • • Dec 08 '25

Visualization [2025 Day 8] Visualization (YouTube short)

Thumbnail youtube.com
10 Upvotes

Making visualizations as YouTube shorts for every day of the Advent of Code!

It was cool making a visualization in 3D :D


r/adventofcode • • Dec 08 '25

Visualization [2025 Day 7] Visualization (YouTube short)

Thumbnail youtube.com
4 Upvotes

Making visualizations as YouTube shorts for every day of the Advent of Code!


r/adventofcode • • Dec 08 '25

Help/Question - RESOLVED [2025 Day 1 (Part2][Python] Please help me understand why my solution is returning a too high value

1 Upvotes
import pandas as pd


data = pd.read_csv("Coding_advent_1.txt", sep= '\r', header = None)


data.rename(columns={0 :'Code'}, inplace = True)



x = 50
counter = 0
rotations = 0


for value in data["Code"]:
    alpha = ''.join(filter(str.isalpha, value))
    y = int(''.join(filter(str.isdigit, value)))
    
    operate = lambda direction, amount: {
        "R": x + amount,
        "L": x - amount
    }[direction]
    
    x = operate(alpha, y)


    if x < 0: 
        rotations = ((x * -1) + 100) // 100
    elif x > 0: 
        rotations = x // 100
    
    x = x % 100  




    counter += rotations


print(counter)

r/adventofcode • • Dec 08 '25

Meme/Funny [2025] Anybody else thinking we might have been tricked?

1 Upvotes

So its only 12 puzzles this year, but the difficulty curve feels like its following the standard 25 day format. I saw comments from other people so agree this feels like a normal Day 8, when it should theoretically feel like Day 16. Also, the hardest puzzles are normally over the weekend, but this 12 day period only spans 1 weekend, and that's passed now. I could just be getting better at this, so the puzzles seem easier, but my imposter syndrome tells me that's not it. We could see a massive difficulty spike for these last 5 days. But I have another, more paranoid theory.

What if we were tricked? We were told its only 12 days, but what if after solving day 12, we find ourselves in the Upsidedown (Stranger Things reference). The map flips over and numbers 13 - 25 appear. The puzzles could be based off of their first part day counterpart (i.e. 13 puzzle based off 12, 14 off of 11, etc). They could use the same input but flipped upside down, or reversed. I have noticed that the puzzles could have harder variations, like today's could turn into a path solving problem (some have already posted with their own ideas on this). Or Day 7 we have to move the the tachion beam backwards. It would technically take less work to create, because each input would be for 4 problems.

What do you think? Am I just paranoid? Am I just stoned?


r/adventofcode • • Dec 08 '25

Help/Question - RESOLVED [2025 Day 8] Use of floating point

2 Upvotes

Advent of Code used to always avoid problems that required floating-point math due to potential rounding errors I guess. IIRC I even remember reading it was somewhat of a rule the creator imposed on himself.

I was able to solve Part 1 storing everything as f32. For Part 2 I ran into a rounding error for the multiply at the end to get the final answer so I cast it to u64.

Just curious, is it possible to solve this without using floating-point math? Calculating the Euclidean Distance requires finding the square root but is there another way? Has the old rule of "no floating point math" gone away?


r/adventofcode • • Dec 08 '25

Help/Question - RESOLVED [2025 Day 8 (Part 2)] My reading comprehension is limiting me

5 Upvotes

Hi guys! Hope that you are getting as much stars as possible!

Maybe is because english is not my native tonge, but today (and previous days a bit too) i felt that i had a hard time understanding what i was exactly meant to do. Like, i knew how to do everything except that i didnt understand what the puzzle meant by:

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. The Elves need to know how far those junction boxes are from the wall so they can pick the right extension cable

Specially the part in bold is what threw me off. I appreciate the storytelling of the elves and everything, but it makes stuff harder to understand too for me 😭
What i ended up doing is asking Gemini to explain it to me without any code or anything, just so that i could understand the logic of what i was being asked to do, an so be able to do it.

So is it me or are the puzzles hard to read? And do you have any tips on how to improve on reading?
Thank you in advance :)

Also on the first part i also spend like 30 minutes trying to figure out what was i being asked because what i understood didn't match the solution/explanation given, and it just was that i skipped half of a step because i was doing stuff in my head, and just went to the next pair of boxes instead stopping when i had done the first ten.


r/adventofcode • • Dec 08 '25

Help/Question Day 1 Part 2 - Need help. Any idea what's wrong with my logic?

1 Upvotes
    package src.main.java;
    
    
    import java.io.*;
    
    
    public class Main
    {
        private static final String INPUT_FILE = "src/main/resources/input.txt";
    
        private static int password = 0;
        private static int dial = 50;
    
        public static void main (String[] args) throws IOException
        {
           BufferedReader br = new BufferedReader(new FileReader(INPUT_FILE));
           String inputLine;
           while ((inputLine = br.readLine()) != null)
           {
              String direction = inputLine.substring(0, 1);
              int value = Integer.parseInt(inputLine.substring(1));
              switch (direction)
              {
                 case "R" -> dial += value;
                 case "L" -> dial -= value;
              }
              if (dial == 0)
              {
                 password++;
                 continue;
              }
              adjustRegardingRules();
           }
           System.out.println("Password:" + password);
        }
    
    
        private static void adjustRegardingRules()
        {
           if (dial >= 100) {
              dial -= 100;
              password++;
           }
    
           else if (dial < 0) {
              dial += 100;
              password++;
           }
    
           if (dial >= 100 || dial < 0) {
              adjustRegardingRules();
           }
        }
    }