public void Part2Tests_File() { const int outputToFind = 19690720; var instructions = File.ReadAllText(InputFile) .Split(',') .Select(x => long.Parse(x)) .ToArray(); var intcodeRunner = new IntcodeRunner(instructions); for (int noun = 0; noun <= 99; noun++) { for (int verb = 0; verb <= 99; verb++) { try { var runnerResults = intcodeRunner.Execute(noun, verb); if (runnerResults[0] == outputToFind) { Console.WriteLine($"Found Matching Result: Noun={noun}, Verb={verb}"); Console.WriteLine($" Output: {noun * 100 + verb}"); } } catch { // If the program encounters an error, ignore it as it means the values didn't result in the desired output. } } } }
public void Part1Tests(long[] instructions, long[] expectedOutput) { var intcodeRunner = new IntcodeRunner(instructions); var runnerResults = intcodeRunner.Execute(); runnerResults.Should().BeEquivalentTo(expectedOutput); }
public void Part2Tests_File() { var instructions = File.ReadAllText(InputFile1) .Split(",") .Select(x => long.Parse(x)) .ToArray(); var intcodeRunner = new IntcodeRunner(instructions); intcodeRunner.InputQueue.Enqueue(2); var runnerResults = intcodeRunner.Execute(); }
public void Part2Tests(long[] instructions, long[] userInput, long[] expectedOutput) { var intcodeRunner = new IntcodeRunner(instructions); foreach (var item in userInput) { intcodeRunner.InputQueue.Enqueue(item); } var runnerResults = intcodeRunner.Execute(); runnerResults.Should().BeEquivalentTo(expectedOutput); }
public void Part2Tests_File() { var instructions = File.ReadAllText(InputFile1) .Split(',') .Select(x => long.Parse(x)) .ToArray(); var intcodeRunner = new IntcodeRunner(instructions); intcodeRunner.InputQueue.Enqueue(5); var runnerResults = intcodeRunner.Execute(); intcodeRunner.GetLastOutput().Should().Be(9168267); }
public void Part1Tests(long[] instructions, long expected, long[] expectedArr) { var intcodeRunner = new IntcodeRunner(instructions); var runnerResults = intcodeRunner.Execute(); if (expectedArr != null) { runnerResults.Should().BeEquivalentTo(expectedArr); } else { intcodeRunner.GetLastOutput().Should().Be(expected); } }
public void Part1Tests_File() { var instructions = File.ReadAllText(InputFile) .Split(',') .Select(x => long.Parse(x)) .ToArray(); // Restore gravity assist. var noun = 12; var verb = 2; var intcodeRunner = new IntcodeRunner(instructions); var runnerResults = intcodeRunner.Execute(noun, verb); Console.WriteLine($"Position 0 Result: {runnerResults[0]}"); }