public void HighestValueEver_ReturnsCorrectly_AfterApplyInstructions() { var runner = new InstructionRunner(); runner.ApplyInstructions("day8testinput.txt"); Assert.Equal(10, runner.HighestValueEver); }
public void EvaluteCondition_ReturnsCorrectly(string condition, bool expected) { var runner = new InstructionRunner(); var actual = runner.ConditionIsTrue(condition); Assert.Equal(expected, actual); }
public void ApplyInstructions_ReturnsCorrectly() { var runner = new InstructionRunner(); runner.ApplyInstructions("day8testinput.txt"); var registers = runner.Registers; Assert.Equal(1, registers["a"]); Assert.Equal(0, registers["b"]); Assert.Equal(-10, registers["c"]); }
public void TestRunInstructions() { var instructions = Testing.GetTestFileContents("TestInput.txt").Split(Environment.NewLine); var instructionRunner = new InstructionRunner(instructions); instructionRunner.RunInstructions(); CollectionAssert.AreEquivalent( new Dictionary <string, int> { { "a", 1 }, { "b", 0 }, { "c", -10 } }, instructionRunner.Registers); Assert.AreEqual(10, instructionRunner.MaxValueHeld); }
public static long Part2(string path) { var instructions = File.ReadLines(path).ToList(); var aRunner = new InstructionRunner(instructions, 0); var bRunner = new InstructionRunner(instructions, 1); var fromA = new Queue <long>(); var fromB = new Queue <long>(); while (true) { fromA = aRunner.RunToStop(fromB); fromB = bRunner.RunToStop(fromA); if (fromA.Count == 0 && fromB.Count == 0) { return(bRunner.SendCount); } } }