2024 Day 24: Crossed Wires

On reading the hint “There are no loops […]”, I have decided to do it all by hand using

  • Excel, for turning inputs into Ada sources and do some basic sorting (for having the z* outputs at the end)
  • LEA (& HAC behind the scenes) for finding the correct dependency order (F4 (compile), cut, paste, F4, …)
  • (part 2) GNAT Studio for refactoring suspicious gate names with very clear names. On my puzzle input, three wrong wires were obvious (anomalies compared to other similar gates on the output side) and I needed to run the function itself with various powers of two to find the fourth anomaly.
1 Like

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! :trophy:

I suppose that could be completely automated, but I don’t feel like putting the effort into it.

Just one more day

1 Like