aoc-2018-python

Advent of Code 2018 Solutions in Python
git clone https://git.sinitax.com/sinitax/aoc-2018-python
Log | Files | Refs | README | sfeed.txt

part1 (2398B)


      1--- Day 21: Chronal Conversion ---
      2
      3You should have been watching where you were going, because as you wander the new North Pole base,
      4you trip and fall into a very deep hole!
      5
      6Just kidding.  You're falling through time again.
      7
      8If you keep up your current pace, you should have resolved all of the temporal anomalies by the next
      9time the device activates. Since you have very little interest in browsing history in 500-year
     10increments for the rest of your life, you need to find a way to get back to your present time.
     11
     12After a little research, you discover two important facts about the behavior of the device:
     13
     14First, you discover that the device is hard-wired to always send you back in time in 500-year
     15increments. Changing this is probably not feasible.
     16
     17Second, you discover the activation system (your puzzle input) for the time travel module. 
     18Currently, it appears to run forever without halting.
     19
     20If you can cause the activation system to halt at a specific moment, maybe you can make the device
     21send you so far back in time that you cause an integer underflow in time itself and wrap around back
     22to your current time!
     23
     24The device executes the program as specified in manual section one and manual section two.
     25
     26Your goal is to figure out how the program works and cause it to halt.  You can only control
     27register 0; every other register begins at 0 as usual.
     28
     29Because time travel is a dangerous activity, the activation system begins with a few instructions
     30which verify that bitwise AND (via bani) does a numeric operation and not an operation as if the
     31inputs were interpreted as strings. If the test fails, it enters an infinite loop re-running the
     32test instead of allowing the program to execute normally.  If the test passes, the program
     33continues, and assumes that all other bitwise operations (banr, bori, and borr) also interpret their
     34inputs as numbers. (Clearly, the Elves who wrote this system were worried that someone might
     35introduce a bug while trying to emulate this system with a scripting language.)
     36
     37What is the lowest non-negative integer value for register 0 that causes the program to halt after
     38executing the fewest instructions? (Executing the same instruction multiple times counts as multiple
     39instructions executed.)
     40
     41