Ejemplo n.º 1
0
        public void GetDay22Part1AnswerTest()
        {
            BigInteger expected = 2519;
            BigInteger actual   = Day22.GetDay22Part1Answer();

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 2
0
        public void Test7()
        {
            var expected = "0 7 4 1 8 5 2 9 6 3";
            var actual   = Day22.SolveAll(10, 10, new string[] { "deal with increment 3" });

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 3
0
        public void Part2RealPuzzle()
        {
            var input  = GetPuzzleInput();
            var result = Day22.SolvePart2(input);

            Assert.Equal(2511345, result);
        }
Ejemplo n.º 4
0
        public void Part2SamplePuzzle()
        {
            var input  = GetSampleInput();
            var result = Day22.SolvePart2(input);

            Assert.Equal(2511944, result);
        }
Ejemplo n.º 5
0
        public void PartATests(string input, int expectedOutput)
        {
            var day    = new Day22();
            var result = day.SolveA(input);

            Assert.AreEqual(expectedOutput, result);
        }
Ejemplo n.º 6
0
        public void Part1RealPuzzle()
        {
            var input  = GetPuzzleInput();
            var result = Day22.SolvePart1(input);

            Assert.Equal(5256, result);
        }
Ejemplo n.º 7
0
        public void GetDay22Part2AnswerTest()
        {
            BigInteger expected = BigInteger.Parse("58966729050483");
            BigInteger actual   = Day22.GetDay22Part2Answer();

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 8
0
        public void GetDay22Part02AnswerTest()
        {
            long expected = 35836;
            long actual   = Day22.GetDay22Part02Answer();

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 9
0
        public void Test3()
        {
            var expected = "0 1 2 3 4 5 6 7 8 9";
            var actual   = Day22.SolveAll(10, 10, new string[] { "deal into new stack", "deal into new stack" });

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 10
0
        public void Test4()
        {
            var expected = "3 2 1 0";
            var actual   = Day22.SolveAll(4, 4, new string[] { "deal into new stack" });

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 11
0
    public void Y2021_Day22_Reboot_Returns_Correct_Value_2()
    {
        // Arrange
        string[] instructions =
        {
            "on x=-20..26,y=-36..17,z=-47..7",
            "on x=-20..33,y=-21..23,z=-26..28",
            "on x=-22..28,y=-29..23,z=-38..16",
            "on x=-46..7,y=-6..46,z=-50..-1",
            "on x=-49..1,y=-3..46,z=-24..28",
            "on x=2..47,y=-22..22,z=-23..27",
            "on x=-27..23,y=-28..26,z=-21..29",
            "on x=-39..5,y=-6..47,z=-3..44",
            "on x=-30..21,y=-8..43,z=-13..34",
            "on x=-22..26,y=-27..20,z=-29..19",
            "off x=-48..-32,y=26..41,z=-47..-37",
            "on x=-12..35,y=6..50,z=-50..-2",
            "off x=-48..-32,y=-32..-16,z=-15..-5",
            "on x=-18..26,y=-33..15,z=-7..46",
            "off x=-40..-22,y=-38..-28,z=23..41",
            "on x=-16..35,y=-41..10,z=-47..6",
            "off x=-32..-23,y=11..30,z=-14..3",
            "on x=-49..-5,y=-3..45,z=-29..18",
            "off x=18..30,y=-20..-8,z=-3..13",
            "on x=-41..9,y=-7..43,z=-33..15",
            "on x=-54112..-39298,y=-85059..-49293,z=-27449..7877",
            "on x=967..23432,y=45373..81175,z=27513..53682",
        };

        // Act
        long actual = Day22.Reboot(instructions, initialize: true);

        // Assert
        actual.ShouldBe(590784);
    }
Ejemplo n.º 12
0
        public void Test2()
        {
            var expected = "9 8 7 6 5 4 3 2 1 0";
            var actual   = Day22.SolveAll(10, 10, new string[] { "deal into new stack" });

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 13
0
        public void Part1SamplePuzzle()
        {
            var input  = GetSampleInput();
            var result = Day22.SolvePart1(input);

            Assert.Equal(5587, result);
        }
Ejemplo n.º 14
0
    public void Y2020_Day22_PlayCombat_Returns_Correct_Value(bool recursive, int expected)
    {
        // Arrange
        string[] values = new[]
        {
            "Player 1:",
            "9",
            "2",
            "6",
            "3",
            "1",
            string.Empty,
            "Player 2:",
            "5",
            "8",
            "4",
            "7",
            "10",
        };

        // Act
        int actual = Day22.PlayCombat(values, recursive);

        // Assert
        actual.ShouldBe(expected);
    }
Ejemplo n.º 15
0
        public void PartATest_Real()
        {
            var day    = new Day22();
            var result = day.SolveA(InputData.Day22);

            Assert.AreEqual(11575, result);
        }
Ejemplo n.º 16
0
        public void Test9()
        {
            var expected = "0 1 2 3 4 5 6 7 8 9";
            var actual   = Day22.SolveAll(10, 10, new string[] { "deal with increment 1" });

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 17
0
        public void Test8()
        {
            var expected = "0 3 6 9 2 5 8 1 4 7";
            var actual   = Day22.SolveAll(10, 10, new string[] { "deal with increment 7" });

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 18
0
    public void Y2015_Day22_Fight_Win_Scenario_2()
    {
        // Arrange
        IList <string> spellsToConjure = new[] { "Recharge", "Shield", "Drain", "Poison", "MagicMissile" };
        int            index           = 0;

        string SpellSelector(Day22.Wizard w, ICollection <string> s) => spellsToConjure[index++];

        var    wizard     = new Day22.Wizard(10, 250, SpellSelector);
        var    opponent   = new Day22.Boss(14, 8);
        string difficulty = "easy";

        // Act
        Day22.Player actual = Day22.Fight(wizard, opponent, difficulty, Output);

        // Assert
        actual.ShouldNotBeNull();
        actual.ShouldBeSameAs(wizard);
        opponent.Armor.ShouldBe(0);
        opponent.Damage.ShouldBe(8);
        opponent.HitPoints.ShouldBe(-1);
        wizard.Damage.ShouldBe(0);
        wizard.HitPoints.ShouldBe(1);
        wizard.Mana.ShouldBe(114);
        wizard.ActiveSpells.ShouldBe(new[] { "Poison" });
        wizard.ManaSpent.ShouldBe(229 + 113 + 73 + 173 + 53);
        wizard.SpellsCast.ShouldBe(spellsToConjure);
    }
Ejemplo n.º 19
0
        public void Day22()
        {
            var day = new Day22();

            Assert.Equal(5460, day.FirstPart());
            Assert.Equal(2511702, day.SecondPart());
        }
Ejemplo n.º 20
0
        public void Test6()
        {
            var expected = "6 7 8 9 0 1 2 3 4 5";
            var actual   = Day22.SolveAll(10, 10, new string[] { "cut -4" });

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 21
0
        public void Test1()
        {
            var expected = "0 1 2 3 4 5 6 7 8 9";
            var actual   = Day22.SolveAll(10, 10, new string[0]);

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 22
0
        public void GetWinnerScoreInRecursiveGame()
        {
            var day22 = new Day22("\\AOCTests\\Day22Tests\\Day22TestInput.txt");

            day22.RunDay22Part2();

            //Assert.AreEqual(291, score);
        }
Ejemplo n.º 23
0
        public void testReadData()
        {
            Day22 day22 = new Day22();

            day22.LoadData(Day22.TestData());
            Assert.AreEqual(5, day22.Player1.Count);
            Assert.AreEqual(5, day22.Player2.Count);
        }
Ejemplo n.º 24
0
        public void Part02(string[] input, int bursts, int expected)
        {
            // Act
            var actual = Day22.Part02(input, bursts);

            // Assert
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 25
0
        public void PartBTests(string input, int expectedOutput)
        {
            // requires:  ExtendX >= 1, ExtendY >= 3
            var day    = new Day22();
            var result = day.SolveB(input);

            Assert.AreEqual(expectedOutput, result);
        }
Ejemplo n.º 26
0
        public void Solve2()
        {
            var input  = DataHelper.Get(22);
            var solver = new Day22();
            var result = solver.Solve2(input);

            Output.WriteLine(result.ToString());
        }
Ejemplo n.º 27
0
    public void Should_calculate_on_cubes_small()
    {
        var inputPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "Day22Tests/Input/example.txt");
        var input     = File.ReadLines(inputPath);

        var result = Day22.CalculateOnCubesSmall(input.ToArray());

        Assert.That(result, Is.EqualTo(39));
    }
Ejemplo n.º 28
0
        public void Day22Part2Test()
        {
            var day22 = new Day22();

            var actual   = day22.Part2(p1, p2);
            var expected = 33212;

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 29
0
        public void Day22Test()
        {
            Day    _day22                 = new Day22("");
            string PartOneExpected        = "Fail";
            string PartTwoExpected        = "Fail";
            Tuple <string, string> Actual = _day22.getResult();

            Assert.AreEqual(PartOneExpected, Actual.Item1);
            Assert.AreEqual(PartTwoExpected, Actual.Item2);
        }
Ejemplo n.º 30
0
        public long Part1(string input, int bursts)
        {
            var sot = new Day22(input);

            for (var i = 0; i < bursts; i++)
            {
                sot.Burst();
                TestContext.Progress.WriteLine($"Burst {i + 1}  => {sot.Infected}");
            }
            return(sot.Infected);
        }