AoC 2020 D8: Handheld Halting
| Problem statement | Source code | Tags: VMBrute force
← Previous Back to AoC Index Next →
Part 1
Not much to say here; just iterate through the instructions, keeping track of which ones have been executed (as line numbers). If we reach an instruction we've already executed, return the accumulator.
Part 2
There may be clever ways to do this, such as building a control flow graph and finding which nop/jmp instructions are on paths that lead to termination, but I brute-forced: for each nop or jmp, swap it, run the program, and see if it terminates. If it does, return the accumulator.