Day 10 - Solutions
Updated my notebook with the Part 2 solution: https://narimiran.github.io/aoc2025/src/day10/ It uses the brilliant insight from Reddit on how to divide and conquer this, without using Z3 or similar: https://old.reddit.com/r/adventofcode/comments/1pk87hl/2025_day_10_part_2_bifurcate_your_way_to_victory/
I am very interested in this, but for the moment I will still stubbornly continue hoping to - slowly - finish my own simplex + branch & bound implementation, after trying a constraint propagation approach that left too many options open to be feasible for the larger target values. All the while I kept thinking that there should probably be a much simpler solution that I just did not yet see… 🙂
Solved it by using loco wrapper for Choco constraint programming Java library... It almost worked except for 1 line, there I had to get the best result from what the solver returned in 10 minutes 🤣 I will post the code later, first time I did such a thing
Just rewrote my Part 2 solution - now it is 5x faster than the initial solution and calculates the result in ~500 ms on my machine. (The link to the notebook is the same one as already posted above)
Finally solved it with Simplex method. I was surprised when it said my answer is too low. It turned out that some solutions with non-integers might give an integer sum. So my wrong answer was just off by 4 🫠
alright i'm out 🙂
OMG... I've just made it. I used linear programming (`linear-optimization` from a fastmath) + branch-and-bound algorithm to convert it to ILP. Simplex + branch-and-bound is enough for part2 problem.
https://github.com/genmeblog/advent-of-code/blob/master/src/advent_of_code_2025/day10.clj
Just Part 1 for me today: https://narimiran.github.io/aoc2025/src/day10/
Yes, realised rather late that this requires linear programming. Will take some time before I have that logic in place in my Scittle environment.
It's worse: integer linear programming...
Kind of disappointed. It's one thing for a problem to make us research algorithms, but to only be (realistically) solveable by reaching for a 3rd-party package seems kind of cheesy.
But, I guess it's time to read up on this LP package...
Regular LP (Simplex method) gives non-integer solution on some cases - so specific adjustment is needed (`branch-and-bound` works fortunately). Or you should use ILP (integer programming) which is harder to implement. There are external libs of course.
Hah I used minizinc for part 2.. clojure for parsing and orchestrating (well..pmapping) calling out to the minizinc binary