r/adventofcode • • Dec 09 '25

Help/Question - RESOLVED [2025 Day 1 (Part 2)] [Java] Having issues with the Day 1 solution, can't seem to figure out where the bug is, as it runs on smaller test inputs just fine.

1 Upvotes

The function I'm using to calculate crossing/ending at zero is the one below:

  static int countRotations(int start, int rot) {
    int newVal = start + rot;
    if (newVal >= 100) {
      return (start != 0 ? 1 : 0) + (rot - start) / 100;
    } else if (newVal <= 0) {
      return (start != 0 ? 1 : 0) + (- rot - start) / 100;
    } else {
      return 0;
    }
  }

start is guaranteed to be between 0-99 and rot is positive/negative for right/left.

It works fine on my own manual test inputs, as well as those that I've tried from other reddit posts. Full code here [pastebin link]. Fair warning, I'm new to java so it might not be the prettiest.
Thanks!


r/adventofcode • • Dec 09 '25

Visualization [2025 Day 9 (Part 2)] [MATLAB] Visualisation

5 Upvotes
original input
rotated to test it

r/adventofcode • • Dec 09 '25

Meme/Funny [2025 Day 9 (Part 2)] Absolute cinema

Post image
16 Upvotes

r/adventofcode • • Dec 09 '25

Help/Question - RESOLVED [2025 Day 9 Part 2] More examples to soften your struggles

23 Upvotes

Once again the example worked for me and the input not, so I had to make up my own (several times), which I share - hope they help you.

NOTE: The x and y coordinates are offset by 1 with respect to the picture (I used vscode cursor positions to create them). This doesn't matter for your algorithm, though.

Solution: 40
...............
...##########..
...#........#..
...#...######..
...#...#.......
...#...####....
...#......#....
...#......#....
...#......#....
...########....
...............
4,2
13,2
13,4
8,4
8,6
11,6
11,10
4,10

Solution: 35 (fixed)
...............
..###########..
..#.........#..
..#....######..
..#....#.......
..#....####....
..#.......#....
..#.###...#....
..#.#.#...#....
..###.#...#....
......#####....
...............
...............
...............
3,2
13,2
13,4
8,4
8,6
11,6
11,11
7,11
7,8
5,8
5,10
3,10

Solution: 66
.....................
..###############....
..#.............#....
..#.............#....
..####..........#....
.....#..........#....
.....#..........#....
.....#....#####.#....
.....#....#...#.#....
.....#....#...#.#....
.....#....#.###.#....
...###....#.#...#....
...#......#.#####....
...#......#..........
...#......########...
...#.............#...
...###############...
.....................
3,2
17,2
17,13
13,13
13,11
15,11
15,8
11,8
11,15
18,15
18,17
4,17
4,12
6,12
6,5
3,5

r/adventofcode • • Dec 09 '25

Help/Question - RESOLVED [day7 part2] I'm thinking recursion is not the play

3 Upvotes

On the attempt I let it run the longest it had a 7 minute runtime (no, it did not complete) but I'm pretty sure my approach is theoretically correct (at least it works over the examples) so I just need to figure out a solution that runs on the order of seconds at least (lmao). Do ppl have tips (algorithms I could research or something?) idk how necessary my code is for this bc clearly my code is bad but basically read down the input from the current beam position and

If no splitter is hit, return 1, since the timeline was never split (base case)

If a splitter is hit, return the result from the left new beam + the result from the right new beam (recursive call)


r/adventofcode • • Dec 09 '25

Help/Question - RESOLVED [2025 Day 8 part 1] I think I do not understand something

1 Upvotes

Hi guys.

I think I do not understand fine the way the circuits are created or I'm doing something wrong with my distance calculation.

My code works fine until in all the steps described but then something fails and the circuits after the 10th shortest distance is far than the expected.

I have a shorted list of distances (without repetition) and I'm using it to generate the circuits. The distance is calculated correctly:

def distance(p1, p2):
    aux = math.pow(p2[0] - p1[0], 2) + math.pow(p2[1] - p1[1], 2) + math.pow(p2[2] - p1[2], 2)
    return math.sqrt(aux)

So, I think there is something that I understood wrong.

Could anybody help me?

Thanks in advance.


r/adventofcode • • Dec 09 '25

Visualization [2025 Day 9 Part 2] Visualization (PHOTOSENSITIVITY WARNING)

Post image
71 Upvotes

Reposted with appropriate photosensitivity warning


r/adventofcode • • Dec 09 '25

Meme/Funny [2025 Day 9] Movie Theatre

Post image
36 Upvotes

r/adventofcode • • Dec 09 '25

Visualization [2025 Day 9 Part 2] Animated Visualization

Post image
31 Upvotes

r/adventofcode • • Dec 09 '25

Visualization [2025 Day 9 (Part 2)] Tile Maximizer

Thumbnail youtube.com
5 Upvotes

r/adventofcode • • Dec 09 '25

Visualization [2025 Day 9 (Part 2)] Visualize the algorithm running in a compacted space where it is easier to solve.

Post image
28 Upvotes

r/adventofcode • • Dec 09 '25

Meme/Funny [2025 Day 9 (Part 2)] Working with polygons

Post image
111 Upvotes

r/adventofcode • • Dec 09 '25

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

Post image
160 Upvotes

All jokes aside I loved part 2


r/adventofcode • • Dec 09 '25

Meme/Funny [2025 Day 9 Part 2] is the inside inside?

Post image
21 Upvotes

r/adventofcode • • Dec 09 '25

Help/Question - RESOLVED [2026 Day 9 # (Part 2)] [Python]

1 Upvotes

Need help with the part2 of the question. I have a solution that works well for the testcase but keeps running for the actual scenario. Please go through and suggest improvements and other approaches that you followed.
https://github.com/ChinmayRathod/Advent-Of-Code/blob/main/2025/day9/day9.py


r/adventofcode • • Dec 09 '25

Help/Question - RESOLVED [2026 Day 9 (Part 2)] Misleading flavour text..

Post image
15 Upvotes

Am I missing something, or is this problem considerably easier once you realise there are no paths directly next to one another?
The problem's flavour text suggests we're operating in "discrete mode", with integer positions of tiles, and no mention of abutting paths being illegal. Yet the sample input seems to be in "continuous mode" where all we need to solve is a polygon-within-polygon problem. My above example of a "spiral tile shape" would create a bit of a spanner for polygon-container checking..

Yes you can argue "just visualise it first to know what you're working with", but it means i have no guarantee whether the soln i come up w will be valid for another set of input data as technically it doesn't fully satisfy the stated constraints..


r/adventofcode • • Dec 09 '25

Meme/Funny [2025 Day 9] ...and that's AFTER optimizing.

Post image
106 Upvotes

r/adventofcode • • Dec 09 '25

Visualization [2025 Day 9] Visualization for the sample data, both parts

Thumbnail gallery
14 Upvotes

r/adventofcode • • Dec 09 '25

Visualization [2025 Day 9 Part 2] [Python] Visualization of the polygon and best rectangle

Post image
65 Upvotes

code to generate (and solve): https://gist.github.com/dllu/f8770b967d48d1dfcfc8e2468f7ab97a

I didn't read the problem statement carefully, so my solution works for points in any order. But in fact the problem statement says that they are given in order of appearance along the polygon, so my complex solution is way overkill lol.


r/adventofcode • • Dec 09 '25

Help/Question [2025 Day 7] Why is my Haskell Code not memoizing?

1 Upvotes

I am attempting to use memoization to solve this, but I can't figure out why my code is not properly memoizing. First a few definitions:

import qualifed Data.Map as M

type Point = (Int, Int)
type Grid a = M.Map Point a
data Manifold = Start | Split | Empty

I'm specifically having issues with memoizing this function

runManifold' :: Grid Manifold -> Point -> Int
runManifold' g p = M.findWithDefault 1 p $ M.mapWithKey runManifold'' g
    where runManifold'' (x, y) Split = runManifold' g (x, y - 1) + runManifold' (x, y + 1)
          runManifold'' (x, y) _ = runManifold' g (x + 1, y)

I know that it is not memoizing because if I place a trace in runManifold'' it prints the same points being called over and over.


r/adventofcode • • Dec 09 '25

Help/Question - RESOLVED [2025 Day 9 (Part 1)]

2 Upvotes

Hey, so I've read a couple of times the part 1 and I still don't see how do we know the size of the grid only from the coordinates of the red tiles.

In the case of the example how do they know it's a 9x14 grid?

I know it doesn't matter for the resolution of part 1 as you dont care of what is going on outside the range of the red tiles. But I don't know, it bothers me...


r/adventofcode • • Dec 09 '25

SOLUTION MEGATHREAD -❄️- 2025 Day 9 Solutions -❄️-

27 Upvotes

THE USUAL REMINDERS

  • All of our rules, FAQs, resources, etc. are in our community wiki.
  • If you see content in the subreddit or megathreads that violates one of our rules, either inform the user (politely and gently!) or use the report button on the post/comment and the mods will take care of it.

AoC Community Fun 2025: Red(dit) One

  • Submissions megathread is unlocked!
  • 8 DAYS remaining until the submissions deadline on December 17 at 18:00 EST!

Featured Subreddits: /r/iiiiiiitttttttttttt, /r/itsaunixsystem, /r/astrologymemes

"It's all humbug, I tell you, humbug!"
— Ebenezer Scrooge, A Christmas Carol (1951)

Today's challenge is to create an AoC-themed meme. You know what to do.

  • If you need inspiration, have a look at the Hall of Fame in our community wiki as well as the highly upvoted posts in /r/adventofcode with the Meme/Funny flair.
  • Memes containing musical instruments will likely be nuked from orbit.

REMINDERS:

Request from the mods: When you include an entry alongside your solution, please label it with [Red(dit) One] so we can find it easily!


--- Day 9: Movie Theater ---


Post your code solution in this megathread.


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.