예제 #1
0
        public void Part2_Answer()
        {
            var day8   = new Day8();
            var actual = day8.FindHighest(TEST_INPUT);

            Assert.Equal(6619, actual);
        }
예제 #2
0
        public void Part1_Answer()
        {
            var day8   = new Day8();
            var actual = day8.FindLargest(TEST_INPUT);

            Assert.Equal(6611, actual);
        }
예제 #3
0
        public void TestLoopStopper()
        {
            var console = Day8.ParseGameConsoleCode("Advent_of_Code_2020.Day8.SampleInput.txt");

            Day8.DoesConsoleLoop(console);

            Assert.Equal(5, console.Accumulator);
        }
예제 #4
0
        public void TestLoopFixer()
        {
            var console = Day8.ParseGameConsoleCode("Advent_of_Code_2020.Day8.SampleInput.txt");

            Day8.FindLoopingFix(console);

            Assert.Equal(8, console.Accumulator);
        }
예제 #5
0
        public void Day08Part2Test()
        {
            var day8 = new Day8();

            var actual   = day8.Part2();
            var expected = 797;

            Assert.AreEqual(expected, actual);
        }
예제 #6
0
        public void Day08Part1Test()
        {
            var day8 = new Day8();

            var actual   = day8.Part1();
            var expected = 1782;

            Assert.AreEqual(expected, actual);
        }
예제 #7
0
        public void Part2()
        {
            var day8   = new Day8();
            var actual = day8.FindHighest(@"b inc 5 if a > 1
a inc 1 if b < 5
c dec -10 if a >= 1
c inc -20 if c == 10");

            Assert.Equal(10, actual);
        }
예제 #8
0
        public void Part1_CheckParser()
        {
            var day8   = new Day8();
            var actual = day8.Parse("b inc 5 if a > 1");

            Assert.Equal("b", actual.Register);
            Assert.Equal(Operation.Inc, actual.Operation);
            Assert.Equal(5, actual.Offset);
            Assert.Equal("a", actual.ConditionRegister);
            Assert.Equal(Condition.GT, actual.ConditionType);
            Assert.Equal(1, actual.ConditionValue);
        }
예제 #9
0
        public void Part1_SetNewRegister()
        {
            var day8 = new Day8();

            var instruction = new Instruction();

            instruction.Register  = "a";
            instruction.Operation = Operation.Inc;
            instruction.Offset    = -100;

            var registers = new Dictionary <string, int>();

            day8.UpdateRegister(instruction, registers);

            Assert.Equal(-100, registers["a"]);
        }
예제 #10
0
        public void Part1_TestFalsePredicate()
        {
            var day8 = new Day8();

            var instruction = new Instruction();

            instruction.ConditionRegister = "a";
            instruction.ConditionType     = Condition.EQ;
            instruction.ConditionValue    = 10;

            var registers = new Dictionary <string, int>();

            var actual = day8.EvaluateCondition(instruction, registers);

            Assert.False(actual);
        }
예제 #11
0
        public void Part1_UpdateExistingRegister()
        {
            var day8 = new Day8();

            var instruction = new Instruction();

            instruction.Register  = "b";
            instruction.Operation = Operation.Dec;
            instruction.Offset    = 12;

            var registers = new Dictionary <string, int>();

            registers.Add("b", 100);

            day8.UpdateRegister(instruction, registers);

            Assert.Equal(88, registers["b"]);
        }
예제 #12
0
        public void Part1_TestTruePredicate()
        {
            var day8 = new Day8();

            var instruction = new Instruction();

            instruction.ConditionRegister = "b";
            instruction.ConditionType     = Condition.GTE;
            instruction.ConditionValue    = 100;

            var registers = new Dictionary <string, int>();

            registers.Add("b", 101);

            var actual = day8.EvaluateCondition(instruction, registers);

            Assert.True(actual);
        }
예제 #13
0
        public void Part2_2()
        {
            List <string> program = new List <string>
            {
                "nop +0",
                "acc +1",
                "jmp +4",
                "acc +3",
                "jmp -3",
                "acc -99",
                "acc +1",
                "jmp -4",
                "acc +6"
            };

            Computer computer = new Computer();

            computer.Load(program);
            int result = Day8.ModifyUntilExecuteToEnd(computer);

            Assert.AreEqual(8, result);
        }
예제 #14
0
        public void Answer2()
        {
            int answer = 1375;

            Assert.AreEqual(answer, Day8.Problem2());
        }
예제 #15
0
        public void Answer1()
        {
            int answer = 1548;

            Assert.AreEqual(answer, Day8.Problem1());
        }