Part 1 is straightforward, methinks.
My solution to Part 2 is semi-interactive. First I spent some time experimenting with simple values of the x
and y
inputs; right away I noticed that if I added 2^n and 0 for some value of n, 4 outputs were wrong. When I added 2^n to itself, I encountered some more interesting results, but then I realized this wasn’t helping me find the problematic gates, so I analyzed the circuits a little and noticed a pattern (later I read on Reddit that it’s a “ripple adder”). I then analyzed the circuit definitions to find deviations from the pattern, and from that output determined which gates to swap. I added a bit of logic to perform those swaps and verified that the circuits now obeyed the pattern. Done!
I suppose that could be completely automated, but I don’t feel like putting the effort into it.
Just one more day…