Unable to load image

rDrama Advent of Code Day 23: LongNose Got Lost On His Long Walk 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)

13
Jump in the discussion.

No email address required.

Wasted hours today trying to be clever and avoid making a proper graph for Part 2. It still needed a graph. Shouldn't have been lazy.

That said, I'm not sure how you can really be efficient with Part 2. Even if you prune useless paths from the stack you still have a massive search space.

Jump in the discussion.

No email address required.

My brute force BFS part 2 has been running for an hour 👍

I can't be arsed to prune, it'll run all night if it needs to.

Jump in the discussion.

No email address required.

How long did it take? Is it done yet?

:#marseyworried:

Jump in the discussion.

No email address required.

It didn't finish lol time to prune the corridors

Jump in the discussion.

No email address required.

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

Jump in the discussion.

No email address required.

Judging anyone whose code contains import networkx subedition

z←' '@('#'∘=)↑⊃⎕NGET'23.in'1
S←{⍵,⍸'.'=⍵⌷z}¨1,≢z
C←(¯1 0)(0 1)(1 0)(0 ¯1)
L←{
   s2←{c←1⌷⍵ ⋄ (c∊S)∨(1<≢⍵)∧c∊f:0 ⋄ (c+C)s1 ⍵}
   j←{n←s2 ⍵ ⋄ 0≡n:⍵ ⋄ ,∘⍵¨⊂¨n}
   l←{n←s2 ⍵ ⋄ 0≡n:⍵ ⋄ ∇n,⍵}
   p←l¨⊃,/j¨,∘⊂¨⍵ ⋄ p←p,⍨⊂l(1 0)(0 0)+1⌷S
   w←1-⍨¨≢¨p ⋄ t←⌽¨(S,⍵)∘⍳¨(1∘↑,¯1∘↑)¨p
   w←⌈/¨t{⊂⍵}⌸w ⋄ t←∪t
   o d←↓⍉↑t ⋄ m←/∘d¨o∘=¨⍳⌈/o
   ⌈/{2≡⊃⍵:+/w[t⍳2,/⌽⍵] ⋄ x←⍵~⍨m⊃⍨⊃⍵ ⋄ 0≡≢x:⍬ ⋄ ⊃,/∇¨(,∘⍵)¨x}1
}

zr←1⌽z='>' ⋄ zl←¯1⌽z='<' ⋄ zd←1⊖z='v' ⋄ zu←¯1⊖z='^'
f←⍸2≤⊃+/zr zl zd zu
s1←{⍺/⍨(z[⍺]∊¨'.^' '.>' '.v' '.<')∧(~(∊∘⍵)∘⊂¨⍺)}
⎕←L f

z←'.'@(∊∘'><^v')⊢z
zo←z='.' ⋄ zr←1⌽zo ⋄ zl←¯1⌽zo ⋄ zd←1⊖zo ⋄ zu←¯1⊖zo
f←⍸3≤zo×⊃+/zr zl zu zd
s1←{⍺/⍨(z[⍺]='.')∧(~(∊∘⍵)∘⊂¨⍺)}
⎕←L f
Jump in the discussion.

No email address required.

Thought I was smart by converting the whole thing into a DAG with weighted edges, then part 2 threw that out the window and I resorted to brute force using horrible spaghetti code. Got the answer just in time though!

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

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.