sevenseacat
Author of Ash Framework
Advent of Code 2025 - Day 10
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
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #performance
- #security










First Post!
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
).
Most Liked
hauleth
Even with this PRs it doesn’t work, as the solver always used downloaded HiGHS binary instead of using user-provided one. In addition to that HiGHS 1.9.0 (which is downloaded) has some bug, which causes wrong result for my input, and if I change version to 1.12.0 it fails, as it requires additional external libraries (OpenBLAS IIRC). I have forked Dantzig to remove the HiGHS downloader (as it is working improperly anyway) in general and make it more into “CPLEX library” that can be then used with any solver and move solvers downloading and management to separate libs. Something like Nx or Ecto is doing. That way it can use Z3, HiGHS or anything else that can ingest this particular file format (and potentially implement other export formats as well).
@mudasobwa I was also thinking about implementing SMT-LIB generator in Elixir, so it would provide a way to use any SMT solver with Elixir without worrying about compiling binaries and stuff.
mudasobwa
There is no interface, Cure invokes z3 via Erlang port https://github.com/am-kantox/cure-lang/blob/main/src%2Fsmt%2Fcure_smt_process.erl
antoine-duchenet
Yes, my solution does not use any solver library:
It’s basically a recursive reparation approach with genetic programming inspiration. Those parameters converged “pretty quickly” :
It took ~5min20sec to give the answer for my input, but I suspect it may vary a lot
Last Post!
KeithFrost
I became obsessed with this problem after it took me a whole day to get a solution to Part 2. I have now implemented three different solutions: one, an exceedingly clever one (I can say this, because I didn’t think of the algorithm) which extends the Part 1 solution by finding all of the ways (with 0 or 1 presses of each button) to match the least significant bits of the desired joltages, and then recursing on the now-even joltages divided by two, until the desired joltages are all zero. I’ll post that one here, because it is the shortest self-contained solution (the other two are a long self-contained Elixir solution which implements Bareiss’s algorithm for reduction of integer matrices and then searches values of the remaining free variables for solutions, and another one that composes Prolog code that invokes SWI Prolog’s CLPQ solver).