For today's puzzle we are given a set of instructions for how to manipulate a single register. The noop
instruction just increments the clock, while the addx
instruction will add the corresponding number to the register.
First we read in the instructions in a parseable form
For the core logic of the puzzle, we'll try to implement a function cycles
that will return a lazy-seq
of the states of the system at every clock cycle.
Having done this, now we're told to pull out the "interesting signals" which are the 20th clock cycle and every 40 after that.
For part 2, we now also have a CRT type monitor in place, and we'll draw something on the screen if it so happens that our CRT cursor is within one space of the horizontal register from the previous section.
We'll use the clerk html viewer here to generate a <pre>
element with the result.
Let's look at the test
## ## ## ## ## ## ## ## ## ## ### ### ### ### ### ### ### #### #### #### #### #### ##### ##### ##### ##### ###### ###### ###### #### ####### ####### #######
Looks good, what about our puzzle input:
### ## # ### ### #### ## # # # # # # # # # # # # # # # # # # # # # # ### # # # # # ### # ## # ### # # # #### # # # # # # # # # # # # # # # # # # ### #### # # ### #### # # ##