Unable to load image

day 15 thread of aoc i guess lol: diamonds are forever

see leaderboard on geeses post

33
Jump in the discussion.

No email address required.

Going from several minutes, to a few seconds, to a thousandth of a second was really satisfying :marseynut: I literally ejaculated

For my solution, I surmised that the open spot would be nestled between four diamonds. As some of you discovered, the secret location would be in an "alleyway" between two diamonds. I took this a step further, and said that it would be in two alleyways at once - one in the +Y direction, one in the -Y direction (perpendicular).

Alleyways are lines, so I found all alleyways and converted them to lines (well, I kept the starting location and the slope of the line). Then I found all intersections between all the lines (I didn't worry about making sure that they actually intersected lol, I just used a continuous line instead of a line segment to make the calculations faster).

I went from testing 2 million+ possible locations to just four, and I think that's pretty neat :marseyexcited:

C:\dev\personal\aoc> python .\15-clean.py
(3446137, 3204480)
TIME: 0.0009992122650146484
Jump in the discussion.

No email address required.

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.