sevenseacat
Author of Ash Framework
Well some of us wanted a difficulty spike - and today we got one ![]()
https://github.com/sevenseacat/advent_of_code/blob/main/lib/y2025/day10.ex
I don’t think there’s any way to solve part 2 in the “naive” way (eg. with a breadth-first search). There’s no way to reduce the search space enough.
The brainwave is that each set of buttons/target joltage can be modelled as a set of simultaneous equations. Of course they’re not nice simultaneous equations, because there’s more variables (buttons) than equations (output values), and you need to add constraints for non-negative and whole numbers….
Name ips average deviation median 99th %
day 10, part 1 78.99 12.66 ms ±3.07% 12.63 ms 13.76 ms
day 10, part 2 6.90 144.82 ms ±6.17% 141.61 ms 175.05 ms
Trending in Challenges
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
antoine-duchenet
I didn’t find any way to solve it with a BFS or some smart DFS, BUT: for those who balk at implementing a equations solver (like me, I was not in the mood today), it is solvable with a genetic programming / iterative reparation approach, the hard part being to get enough guaranties that the solution is the actual minimum.
It is pretty random, and maybe not very elegant, but at least it did the job with my input (and took a lot more time to run than an equation solver would
).
Bumbus
Thats been a tough one.
I used glpsol now. Took one second to run it for some reason:
In solver function like this:
rvnash
I tried all sorts of things to speed up my native approach to two, including parallelizing it, but alas it’s too large for this approach.
Thanks for the hint on simul equations. Maybe I’ll circle back to see if I can do that before I cheat further and look at your code.
hauleth
P1 was simple thanks to few observations, but P2 was pain (and there were some issues with Dantzig library that I needed to provide workarounds.
Parse
Part 1
Part 2
lud
I finally abandonned my heuristic/cache/sorting/pruning semi-brute force approach, couldn not make it work.
I did not know about z3, which seems that everyones uses on the subreddit, so here it goes
lud
Also maybe @mudasobwa could you tell me how to use z3 with erlang modules. I’ve seen that Cures uses z3 but is there an API for it? I found the same kind of string that we would input to z3 stdin.
sevenseacat
Yeah there’s some PRs open to fix both of those issues, so I used that branch from GitHub
rvnash
Has anybody seen any solution that doesn’t use a solver library? I’ve got to think there is something about the simplicity, 1 and 0 coefficients, of these linear equations that could be taken advantage of.
lud
I found two, one claimed 35minutes runtime, the other one 20 (python)
rvnash
If anyone is still interested in thinking about this, here is a thought I have. This is my set of simultaneous equations for the first machine of the sample data. The format is a tuple of the coefficients list and result of each equation.
The first equation tells us the [b0,b1] pair must be one of these combination: [0,3],[1,2],[2,1],[3,0].
Those combinations will then combine in the next equation to give a set of possible values for b4. For example [3,0] only allows b4 to be 0,1, or 2
Then those combinations will combine in the 3rd equation to add in the combinations of b2 and b5
And then finally add all the combinatorics for the 4th equation.
Also, along the way we’re going to find empty set combinations, i.e. no possible solutions, which means that we can eliminate previous combinations as we go.
It feels like I should sort the equations to minimize the number of new combinations I need to build up in the next step.
Granted this is the simplest machine. But, if you follow this thinking, and did it for one of the “real” problems, would it blow up into the stratosphere? Or would that incremental removal of unsolvable combinations whittle it down as you go into a set of combinations that could actually be evaluated?