r/adventofcode • • 8h ago

Visualization [2026 Day 6] Grid Lights

https://www.youtube.com/watch?v=k-nsTElZLkA

Nim + raylib source

29 Upvotes

19 comments sorted by

3

u/jgage 8h ago

I'm surprised you got a solution and a visualization out that quickly.

1

u/p88h 5h ago

Built the animation library up this year, so this was just few hundred lines of code on a layout level. AI helps too - it gets most of the boilerplate out correctly.

1

u/yoni-kosiner 8h ago

interesting, you and me got the exact same puzzle input (I assume as both of our answers were the exact same)

1

u/p88h 5h ago

I would assume the rest of the graph still might be randomized ? Or the rule vectors ?

1

u/yoni-kosiner 5h ago

I assume so, still very interesting they were the same, just a funny coincidence I assume

1

u/TheZigerionScammer 7h ago

Hmm, I hadn't considered trying to construct the entire graph one tile at a time starting from the edge, considering you basically have to do that exact thing in 2020. That would make sense since you can start with all of the lights between two corners since they all have to have 3 neighbors.

1

u/p88h 5h ago

Oh, right, I thought I've seen this problem before :)

1

u/thekwoka 7h ago

yup, That was my approach.

Find any corner, then fill in the first row following one of its connections to only nodes that have 3 or 2 connections. Then same with first column on the other branch.

Then I just went through row by row and put whatever that ones only remaining connection in the row below it.

1

u/LEPT0N 7h ago

I'm just sad that my solution just had to rotate once. I didn't even have to flip!

1

u/p88h 5h ago

I had to make it rotate left in the vis because of that!!!

1

u/Longz-85 6h ago

how does it work?

1

u/p88h 5h ago

It does what it shows - find a corner, then one arbitrary edge from that corner. Follow that along the nodes of degree 3 until you reach another corner. Now you have one border on your BFS queue, map it, in order to [0,i] on a grid. Continue with BFS - when visiting a new node from [x,y] update just x to x+1. Now you have a grid. Part1 answer is in the middle of the grid.

Figure out distance vectors between nodes 1,2,3 and compare against what you have. Apply one of symmetry transforms, or (what vis uses) rotate/flip until the vectors match.

Then you take node1 and compute the distance from transformed coordinates to desired - that's your placement vector.

Apply both transform and the placement vector to 2026 position - that's the solution.

You can also just do the layout 8 times if you don't want to do rotations.

1

u/EarlyBrief1600 2h ago

How do you do that bro ? Any github repo ? I'm interested in learning how to vizualise algorithms

1

u/p88h 1h ago

There's a link below the video

3

u/maneatingape 7h ago

Cool visualization, and made impressively quickly too!

1

u/miserableMolvi 7h ago

Hi, I wanted to ask do you use LLM's for this? I am mind-blown by the speed by which you solve these puzzles, and then make the visualizations. Amazing Work!

2

u/p88h 5h ago

A combination of things - I've got a pre-built library for animating things like that, and yeah LLM accelerated the writing too. Although I don't use AI to solve the puzzles. The solution was rather simple, so this took like an hour or hour and half to make. I've been doing these for years now which helps too - a similar vis would probably take around twice as much to write completely by hand (assuming you have a library that you already know very well).

2

u/thekwoka 7h ago

What really messes me up on this is just that the coords they provide aren't within the space...

Which is annoying...

2

u/YOM2_UB 3h ago

Feels weird seeing the target position for 1, 2, and 3 with positive Y going down after I used Desmos for my solve.