13
๐ค - 2024 DAY 24 SOLUTIONS - ๐ค
(programming.dev)
An unofficial home for the advent of code community on programming.dev!
Advent of Code is an annual Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.
Solution Threads
M | T | W | T | F | S | S |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 |
Icon base by Lorc under CC BY 3.0 with modifications to add a gradient
console.log('Hello World')
Haskell
Part 1 was trivial, just apply the operations and delay certain ones until you have all the inputs you need.
Code
For part 2 I tried symbolic solving to detect discrepancies but I wouldn't achieve anything with it.
SymbolicEquation
My solution was to use the
dotEngine
-function to translate the operations into a digraph in graphviz-style which I simply plotted and searched through using a python script.dotEngine
I took a loook at the initial graph which was a vertical line with a few exception which I figured would be the misordered wires. I did try some hardware-simulations in the far past to build bit-adders which helped me recognize patterns like carry calculation. First I replaced all occurences of
x__ XOR y__ -> w
withx__ XOR y__ -> xor__
to recognize them more easily. The same withAND
of xs and ys. Using the following script I would then use some Regex to search for the rules that corresponded to carry calculations or structures I knew. The script would break exactly four times and I would then figure out what to switch by hand through looking at the updated graphViz.Please excuse the bad coding style in the script, I had written it on the ipython-REPL.
python script
When solving such a swapped wire problem I would then use my haskell function to plot it out again and stare at it for a few minutes until I understood wich parts belonged where.
The last one looked like this

In this one I needed to switch
jdr
andcarry31
to make it work.