3 ms·
I implemented a very similar solution to the one in the OP in Python, abusing the superpowers granted by Pandas. (Using Pandas was strictly necessary, Python it
by qsort 5y ago
I implemented a very similar solution to the one in the OP in Python, abusing the superpowers granted by Pandas. (Using Pandas was strictly necessary, Python itself is too slow)
The "correct" solution to the problem is, as often is the case for Advent of Code, too tedious to implement: since the only way the program behavior changes is if the states of the registers diverge after an input operation, you can consider inputs that lead to the same states as "related". The coarsest partition with respect to this relation may be found by partition refinement. (https://en.wikipedia.org/wiki/Partition_refinement https://en.wikipedia.org/wiki/Partition_refinement)
Assuming an efficient representation of the search space, this results in a solution that does the minimum amount of work possible.