This is a very silly Advent of Code day to do in Dusa, numeric manipulation imperative state update is NOT the vibe.

For part 1, I had to do modulus by repeated subtraction

Here’s the program on dusa.rocks

Here’s the program on val.town

For part 2, I did write up the whole solution in Dusa:

Here’s the program on dusa.rocks

…but while yesterday I was surprised when performance was poop, today I was totally unsurprising when performance was poop. Making a copy of 255 facts on every step to represent that they didn’t change when the other 1 fact changed is just gonna be really really slow.

But because I’d written out all the logic for the interpreter, including the add-to-list and remove-from-list logic that needed a magic-sets transformation, what I could do was take just the first part of the above program and query out the 256 independent programs, since every instruction only manipulates a single box. Each of the 256 independent programs were reasonable to run and ran quickly in Dusa.

Here’s just the execution logic program on dusa.rocks

Here’s the combined program on val.town