internal static int FindAccumulatorValueOnRepeat(IEnumerable <string> input) { var bootCode = new BootCode(input); bootCode.ExecuteUntilRepeatedInstruction(); return(bootCode.Accumulator); }
internal static int FindAccumulatorValueAfterModification(IEnumerable <string> input) { var bootCode = new BootCode(input); for (var i = 0; i < bootCode.NumberOfInstructions; i++) { if (!bootCode.Modify(i)) { bootCode.Reset(); continue; } if (bootCode.ExecuteUntilEndOfProgram()) { return(bootCode.Accumulator); } bootCode.Reset(); } throw new Exception("ohno"); }