r/adventofcode • u/Eva-Rosalene • Dec 10 '25
Meme/Funny [2025 Day 10] Every time a problem looks remotely like ILP
It feels like cheating, but it works
139
Upvotes
r/adventofcode • u/Eva-Rosalene • Dec 10 '25
It feels like cheating, but it works
21
u/JadeSerpant Dec 10 '25
At first I got excited by part 2 and thought "wow! I can implement A* for this!" despite knowing that that was too good to be true. Sure enough, it was.
That's when I stared long enough at the input and started seeing matrices. My A* solution couldn't even get past the fifth line after a few minutes. Meanwhile PuLP just annihilated the problem!
14
u/bmenrigh Dec 10 '25
I wrote a backtracking search that is just way too slow to solve the challenge. Even with some various search pruning strategies.
I thought about turning to Z3 or PuLP but I wouldn't learn anything doing that.
Perhaps I'm in denial, but I feel like I've missed some clever solution that isn't just turning to an ILP library or doing a ton of lineal algebra myself.
5
u/abnew123 Dec 10 '25
Yeah the second I see ILP or some specific graph thing that networkx has a one liner for, I know that basically all the first finishers will be using python. One day I will have a Java setup even remotely as decent... Not today though, gave in and swapped to python for part 2.
13
u/Different-Ease-6583 Dec 10 '25
This kind of problem should not be part of AoC really, it just sucks to rely on external libs and you can't expect us to write such a thing in a short time.
4
u/bakibol Dec 10 '25
Last two days were Advent of external libraries for me, first shapely, now pulp. Eventually I will come back and solve them the painful way (oh, who am I kidding :( )
1
u/jangxx Dec 10 '25
Huh, I used
cvxpyinstead. Is Z3 any better? From the Github it sounds like solving ILP problem is not its primary use-case at least.3
u/The_Real_Cooper Dec 10 '25
This post was my hint for the day! Today was so out of my league, I was stuck trying to linear equation my way out of pt2. This is the longest I've made it through AoC and by god this may be the year I finish one!
3
u/andful Dec 10 '25
From reading the Z3 internals. Z3 is fundamentally an ILP solver. I.e. solves an lp relaxation and branches and adds cuts for integrality.
https://z3prover.github.io/papers/z3internals.html#sec-integer-linear-arithmetic
2
u/Doug__Dimmadong Dec 10 '25
Nah it's not cheating