Implement a program that simulates the execution of the instructions given in the input
Keep track of the value of the X register and the cycle number
Calculate the signal strength (cycle number x value of X register) during the 20th cycle and every 40 cycles after that
Use a while loop to iterate over the instructions and a switch or if statement to execute the instructions
For the addx instruction, update the value of the X register according to the value of V
For the noop instruction, do nothing
After simulating the execution of the instructions, use a for loop to calculate and print the signal strength at the 20th, 60th, 100th, 140th, 180th, and 220th cycles.
It is not necessary to iterate every cycle, you can choose to keep track of the register and cycles only
You will now need to iterate every cycle and draw each pixel being rendered
The row and column of pixel being rendered are both calculated from the current cycle alone
You can use the answer to part 1 and when changes occur to determine when the pixel should be a ”#” or ”.”