adventofcode

Ivana 2023-12-25T15:39:08.830149Z

Day 25 — Solutions

jurjanpaul 2024-01-08T19:27:04.189729Z

Not knowing, nor finding, an appropriate algorithm, just ‘discovered’ (after a day failing to come up with anything) an approach that works (for my input?): start with a random node as the start set and keep adding the neighbour node that adds the least new edges connecting the set to nodes outside the set, until there are exactly 3 such edges connecting to neighbours outside the set. Takes about 15 seconds on my phone.

roklenarcic 2024-01-05T12:13:42.191769Z

4 seconds

Ivana 2023-12-25T15:42:15.462519Z

Solved via Bell-Fordmann, by finding the most popular edges in all the patsh from each node to others. When yor visualisator helpes with demo data and does not help with real one 😁

👏🏻 1
2023-12-25T16:44:15.377119Z

Super lazy today Used graphviz to find the edges to remove and then loom to do the traversals. 🙂

rjray 2023-12-25T16:53:21.740549Z

https://github.com/rjray/advent-2023-clojure/blob/master/src/advent_of_code/day25.clj This one SHOULD have been a breeze; I have an implementation of Karger's Algorithm from when I did the Coursera 4-class Algorithms Specialization years ago. Only... I couldn't understand my old code. I had left comments, but not enough I guess. And it required some manual adjusting to the number of iterations run in order to guarantee a cut-size of 3.

👍🏻 1
roklenarcic 2023-12-25T19:26:26.770589Z

I used max flow algorithm to find a max flow map where max flow is 3, then I just tried removing combinations of 3 edges from that flow until I got one. That flow has 33 edges so that works fast.

roklenarcic 2023-12-25T19:26:58.512929Z

But I am wondering if there’s some way to get cut set from flow map more directly, without trying every combination of those 33 edges

Waqas Ali 2023-12-26T03:41:17.868019Z

used karger's algorithm as well https://github.com/WaqasAliAbbasi/advent-of-code/blob/main/2023/clojure/src/advent_of_code/day_25.clj

wevrem 2023-12-26T03:45:11.216999Z

My implementation of Karger’s runs fine on the sample, but still has not returned a result on the input. I’ll just let it heat up my computer for a little while longer…

wevrem 2023-12-26T04:17:04.326329Z

… okay, it finally finished. My https://github.com/wevre/advent-of-code/blob/master/src/advent_of_code/2023/day_25_wires.clj is short and sweet, but it doesn’t run very fast. When it returns an answer (sometimes it doesn’t) it takes about 40 seconds (one time it finished at a blazing pace of 12 seconds!). I wish I knew better concurrency tricks, I’m not very experienced with that sort of thing.

roklenarcic 2023-12-26T09:13:58.709019Z

mine works in 4 sec

rjray 2023-12-27T00:21:32.118629Z

Thing about Karger’s, is that it uses random selection. You always have to sample multiple times to endure getting the result you need. I’m working on a rewrite of parts of mine to not have the iteration hard-coded, but my use of pmap is causing some issues.

Aleks 2024-01-04T17:53:18.669649Z

@roklenarcic how long your solution takes?