part2 (1646B)
1--- Part Two --- 2 3After some careful analysis, you believe that [1m[37mexactly one instruction is corrupted[0m. 4 5Somewhere in the program, [1m[37meither[0m a jmp is supposed to be a nop, [1m[37mor[0m a nop 6is supposed to be a jmp. (No acc instructions were harmed in the corruption of this boot code.) 7 8The program is supposed to terminate by [1m[37mattempting to execute an instruction immediately 9after the last instruction in the file[0m. By changing exactly one jmp or nop, you can repair the 10boot code and make it terminate correctly. 11 12For example, consider the same program from above: 13 14nop +0 acc +1 jmp +4 acc +3 jmp -3 acc -99 acc +1 jmp -4 acc +6 15 16If you change the first instruction from nop +0 to jmp +0, it would create a single-instruction 17infinite loop, never leaving that instruction. If you change almost any of the jmp instructions, the 18program will still eventually find another jmp instruction and loop forever. 19 20However, if you change the second-to-last instruction (from jmp -4 to nop -4), the program 21terminates! The instructions are visited in this order: 22 23nop +0 | 1 acc +1 | 2 jmp +4 | 3 acc +3 | jmp -3 | acc -99 | acc +1 | 4 [1m[37mnop[0m -4 | 5 acc 24+6 | 6 25 26After the last instruction (acc +6), the program terminates by attempting to run the instruction 27below the last instruction in the file. With this change, after the program terminates, the 28accumulator contains the value [1m[37m8[0m (acc +1, acc +1, acc +6). 29 30Fix the program so that it terminates normally by changing exactly one jmp (to nop) or nop (to jmp). 31[1m[37mWhat is the value of the accumulator after the program terminates?[0m 32 33