Unable to load image

rDrama Advent of Code Day 11: Orbital Mechanics Edition

Summary for those just joining us:

Advent of Code is an annual Christmas themed coding challenge that runs from December 1st until christmas. Each day the coding problems get progressively harder. We have a leaderboard and pretty good turnout, so feel free to hop in at any time and show your stuff!

Whether you have a single line monstrosity or a beautiful phone book sized stack of OOP code, you can export it in a nice little image for sharing at https://carbon.vercel.app

What did you think about today's problem?

https://adventofcode.com/2023

Our Code is 2416137-393b284c (No need to share your profile, you have the option to join anonymously if you don't want us to see your github)

19
Jump in the discussion.

No email address required.

Stunning insight that this is manhattan distance the rest is hideous but idc, would iterating through the 'blank_' set be better than walking along the path?

https://i.rdrama.net/images/17022892040108328.webp

Jump in the discussion.

No email address required.

>spent most of my time using Kruskal's to find the shortest path before realising that's not what the question wanted at all

:#marseyclown3:

⎕PP←20
r←↑⊃⎕NGET'11.in'1
w←{1+∧/'.'=⍵}
d←{+/∊(⊢×(∘.<⍨∘⍳)∘≢)(∘.{+/|⍺-⍵})⍨⍵}
⎕←d⍸'#'=⍉(w⊢⍤/⍉)(w∘⍉⊢⍤/⊢)r

M←¯1+1000000 ⋄ g←⍸'#'=r
a←{+\∧/'.'=⍵} ⋄ z←{⍵+M×⍺⌷⍨⊂⍵}
x←(a⍉r) z 2⊃¨g ⋄ y←(a r) z 1⊃¨g
⎕←d y,¨x
Jump in the discussion.

No email address required.

He knew what he was doing using those words, I was halfway through a distance matrix when it clicked for me.

Jump in the discussion.

No email address required.

Part 2 made it much easier. I didn't think to reason that way in Part 1 and was doing string replacement, which is not fun in Nim, took me forever. That fricker kinda shapes your perspective on the solution in the way he words the problem.

Part 1:

https://i.rdrama.net/images/17022758211399465.webp

Part 2:

https://i.rdrama.net/images/17022758220207987.webp

Jump in the discussion.

No email address required.

https://i.rdrama.net/images/17022800535939176.webp

Missing a cool function from Python? Just copy it :marseygigachad:

Jump in the discussion.

No email address required.

https://i.rdrama.net/images/17022777203189707.webp

Jump in the discussion.

No email address required.

Is your distance taxicab metric?

Jump in the discussion.

No email address required.

Yes. I learned it as the manhattan distance, but it's just

d = |x_1 - x_2| + |y_1 - y_2|

We add the expansion to the vertical and horizontal distance times however many rows/columns without galaxies we cross over.

Jump in the discussion.

No email address required.

unwashed. Change dis for p1 and p2

https://i.rdrama.net/images/170227590042184.webp

Jump in the discussion.

No email address required.

That was a fun one

https://i.rdrama.net/images/17022762772028537.webp

Jump in the discussion.

No email address required.

https://i.rdrama.net/images/17023312759767601.webp

Not gonna bother cleaning this up. This whole 999,999 not 1,000,000 really threw me off at first.

Jump in the discussion.

No email address required.

No issues today, got the distance just being (x2-x1)+(y2-y1) immediately thank god.

For part 2 just replaced all the empty rows and columns with a third character and incremented by 1M whenever I encountered one.

Pretty gentle, was nice

Jump in the discussion.

No email address required.

I would have gotten such a good time if I realized that np.where returned ypts,xpts :marseydepressed:

https://i.rdrama.net/images/17022726494024663.webp

Jump in the discussion.

No email address required.

This one wasn't too bad at all because I could already guess right away what part 2 was going to be, so I never bothered with maintaining a sparse grid.

https://i.rdrama.net/images/1702313310227939.webp

https://i.rdrama.net/images/1702313311024391.webp

Jump in the discussion.

No email address required.

That was so much easier than yesterday which is good, because I have real, paying work I should be doing on a fricking Monday.

Jump in the discussion.

No email address required.

darn my first reaction was to unironically have an array length in the millions lmaoo

https://i.rdrama.net/images/1702344743552145.webp

Jump in the discussion.

No email address required.

ah man I remember seeing a video on this, some algorithm that solved for smoother lines on a pixelated screen

Jump in the discussion.

No email address required.

You do NOT need that lmao. It's just the taxicab distance (|dx| + |dy|)

Jump in the discussion.

No email address required.

yeah i realized after looking at it again lol I'm paranoid about random curveballs now

Jump in the discussion.

No email address required.

Jump in the discussion.

No email address required.

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