You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The SignalGenerator class is constructed using the input instructions.
The Start(int i) method starts the process at i, which runs until a signal (repeated pattern) is identified (the value in the 'a' register is repeated).
When a signal is identified, the generator is stopped, and the signal is inspected to see if it matches the expected signal (0, 1, 0, 1, 0, 1 ...).
If the signal doesn't match... the process is repeated at i+1, until a solution is found.
If the signal does match... the SignalOutput event (which contains the signal, and the input required to produce the signal) is raised.
The Solver class is constructed usign the input instructions
It creates and wires up an instance of SignalGenerator
The Start method is then called on SignalGenerator with an initial value of 0
The Solver then waits for the SignalGenerator to raise the SignalOutput event, which contains the solution value.
First, the shortest path to moving the empty node to to the target node is determined via a bread-first search
Then the steps required to move the goal data to 0,0 is calculate, knowing that 5 moves are required to move the goal data one step to the left
Part 2 runs in about 30 seconds.
Day 21
Unit tests for each operation and combined operations
For the rotate based on position of letter X instruction reversal, I calculated where each index ends up in part 1, then put those indexes into an array and use it to map sequences when in reverse. I suspect there's an easy way to reverse the original formula.
Uses standard System.Security.Cryptography for MD5
Note: most of the unit tests have an Assert.Inconclusive() so they will be skipped. These solutions require sequential crypto calls, so they take a while to run.