I finished 4th overall in Advent of Code 2023!

preview_player
Показать описание
Advent of Code 2023, Day 25. I finished 38th on part 1 and 34th on part 2 (clicking the button). This was enough to take me into 4th place on the global leaderboard!!!

At first I missed the "remove 3 edges" bit and thought it was just asking us to find the 2 different connected components, which I wrote and got a wrong answer for - then I read more carefully and realized. From there I thought about a few things including min-cut, but I saw the leaderboard filling up and thought there was no way people were writing min-cut that quickly (or that many had prewritten implementations for it) so I wasted a bit of time thinking about heuristic-y approaches.

I thought about NetworkX, which I have installed, but since I had literally never used it before I was a little apprehensive about the time it would take me to figure out how to do basic stuff with us - luckily for me, the documentation page for [minimum_cut] is quite good, so it went quite quickly. One hack I did was I just picked a source and a sink node randomly, and kept re-picking until the min-cut was 3. I'm guessing NX has a way to just find min-cut that disconnects the graph anywhere, but since I knew the min-cut value, this was good enough for me.

Really happy about my final finish, 4th was the absolute best-case finish for me going into tonight, and I thought it was pretty unlikely to happen.

As always, thanks for the problems Eric - it's been great this year!
Рекомендации по теме
Комментарии
Автор

Congrats!! Amazing performance, every time I solved a day I came back to your video to see your solve😄 Thanks for making these

thijsyo
Автор

Thanks man for all your effort and sharing this. Happy new year (^_^)

ytwhiletrue
Автор

Hello @Neil, any chance you release the videos for the 2023 days missing so far? I really like your live videos of AoC, very impressive performance!

MB-qnqt
Автор

GG!! You really kicked into high gear these last few days. Excited to see those videos!

I wonder how much working on them in Korean time helps. I've been doing them first thing in the mornings but stayed up till midnight to do day 23 and that was rough -- definitely not operating at 100%!

benjamineskildsen
Автор

Nice dude! By no means I could beat your time. But I still think I solved it "better" in some way=). What I did is I simply visualized the graph. And all 3 connections are clearly visible by naked eye. Then manually remove them from the input and count nodes in two completely separate clusters.
I do acknowledge it's a hacky way to solve the challenge but no more than using a library.

ppka_enota
Автор

Hoq did you make the interpreter auto open when you had a runtime error?

rafaeldietrich
Автор

IDEK what's even happening, I made it to only day 7😭😭 but congrats

ethanperry
Автор

nice, congrats to 4th!
if Jonathan would 10 sec faster, I think he would pass you
but anyway, I like how you interactively get the answer ;-)
this code should do it automagically (nx ;-)
no random points are necessary

G = nx.Graph()
for line in lines:
name, right = line.strip().split(":")
components = right.split()
for c in components:
G.add_edge(c, name)

edges_to_remove = nx.minimum_edge_cut(G)

groups =
assert len(groups) == 2
g1 = len(groups[0])
g2 = len(groups[1])
res = g1 * g2
return res

rastislavsvoboda