public void PartTwo() { //< Parse the data into memory - generate an initial Handheld var input = Helpers.FileHelper.ParseFile(InputFile); var handheld = new HandheldGameSystem(input); //< Get the indices we may want to alter var indicesToTry = handheld.GetIndicesToTry(new string[] { "nop", "jmp" }); int goodVal = -1; foreach (var idx in indicesToTry) { //< Reset the HandheldGameSystem back to 'normal' (the lazy way) handheld = new HandheldGameSystem(input); //< Run it with the swap var res = handheld.RunWithSwap(idx); if (!res.WasInfiniteLoop) { goodVal = res.Accumulator; break; } } Assert.IsTrue(goodVal == 797); }
public void Test_KnownProgramWithSwap() { var input = Helpers.FileHelper.ParseFile(TestFile); var handheld = new HandheldGameSystem(input); var res = handheld.Run(); Assert.IsTrue(res.Accumulator == 5); }
public void PartOne() { var input = Helpers.FileHelper.ParseFile(InputFile); var handheld = new HandheldGameSystem(input); var indicesToTry = handheld.GetIndicesToTry(new string[] { "nop", "jmp" }); var res = handheld.Run(); Assert.IsTrue(res.Accumulator == 1782); }