Unable to load image

rDrama Advent of Code Day 25: Stop Eating And Code 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)


This is it, we're at the end now. Did you finish it all?

15
Jump in the discussion.

No email address required.

Changed my mind, got the correct solution and it's a v neat puzzle.

First 5 lines are parsing the input, there's nothing to it:

a←⎕C⎕A ⋄ r←(∊∘a⊆⊢)¨⊃⎕NGET'25.in'1
rk←⊃,/1↑¨r ⋄ rv←1↓¨r ⋄ k←∪⊃,/r
u←{(≢rk)<i←rk⍳⊂⍵:⍬ ⋄ i⊃rv}¨k
v←(⌷∘rk)∘⊂∘⍸¨↓⍉∨/¨rv(∘.∊)⊂¨k
T←≢i←k∘⍳¨u,¨v
⎕←{
    c←(≢~∘⍵)∘(⊃∘i)¨⍵
    3≡+/c:T(-×⊢)≢c
    ⍵~⍵⊃⍨⊃⍒c
}⍣{2>≢⍺}⊢⍳≢i

Full calendar:

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

Jump in the discussion.

No email address required.

It's a shame nobody can read that language to figure out what you're actually doing

Jump in the discussion.

No email address required.

Since every node has 4+ connections and the cut size is 3:

>start with a set of all nodes

>for each node in the set, count the number of nodes it maps to outside the set

>add them up, if it's 3, you have the min cut

>if not, remove the element with most outside edges (random to start with) and go back to step 2

It can trip up if crosses the bridge early on, but 99% of the time it gives the right answer.

Jump in the discussion.

No email address required.

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