Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
The way I solved this was by squinting a little and realizing that every time a div instruction happened, then a certain number following it needed to be 0, depending on the value of certain constants embedded in the code, and also on certain other fields in the input. So instead of starting with an input number, it is possible to calculate the min and max values the fields may contain right there, as long as we embed the field positions in a stack.
As this is only going through the code once, this is virtually instantaneous and ended up as the day that was fastest of all days to compute.
https://github.com/yxhuvud/aoc21/blob/main/day24.cr
I spend some days writing a program which construct an expression tree (actually a DAG) from the instruction and then through applying logic derives the equations between the input values for when the final result must be zero. But this was after analyzing the puzzle itself and understanding how the puzzle worked. In a sense it automated the analyzes I performed myself on my own input. The program works for all possible puzzles and very quickly finds a solution. For the details see: https://github.com/FransFaase/AdventOfCode2021#tuesday-decem...