コード例 #1
0
    public void Y2021_Day03_GetLifeSupportRating_Returns_Correct_Value()
    {
        // Arrange
        string[] diagnosticReport =
        {
            "00100",
            "11110",
            "10110",
            "10111",
            "10101",
            "01111",
            "00111",
            "11100",
            "10000",
            "11001",
            "00010",
            "01010",
        };

        // Act
        int actual = Day03.GetLifeSupportRating(diagnosticReport);

        // Assert
        actual.ShouldBe(230);
    }
コード例 #2
0
        public void Day03_Part2_Examples()
        {
            var d = new Day03();

            Assert.AreEqual(3, d.SolutionPart2("^v"));
            Assert.AreEqual(11, d.SolutionPart2("^v^v^v^v^v"));
        }
コード例 #3
0
ファイル: DayTestCases.cs プロジェクト: jjermanis/aoc2020
        public void Day03()
        {
            var d = new Day03();

            Assert.AreEqual(216, d.SimpleTreeCount());
            Assert.AreEqual(6708199680, d.TreeCountProduct());
        }
コード例 #4
0
    public void Y2021_Day03_GetPowerConsumption_Returns_Correct_Value()
    {
        // Arrange
        string[] diagnosticReport =
        {
            "00100",
            "11110",
            "10110",
            "10111",
            "10101",
            "01111",
            "00111",
            "11100",
            "10000",
            "11001",
            "00010",
            "01010",
        };

        // Act
        int actual = Day03.GetPowerConsumption(diagnosticReport);

        // Assert
        actual.ShouldBe(198);
    }
コード例 #5
0
        public void TestTreesHit()
        {
            IList <string> rawInput = new List <string>
            {
                "..##.......",
                "#...#...#..",
                ".#....#..#.",
                "..#.#...#.#",
                ".#...##..#.",
                "..#.##.....",
                ".#.#.#....#",
                ".#........#",
                "#.##...#...",
                "#...##....#",
                ".#..#...#.#"
            };
            IList <IList <bool> > input    = Helpers.ApplyTransformation(rawInput, Day03.GetTreeIndices);
            const int             dx       = 3;
            const int             dy       = 1;
            const long            expected = 7;

            long actual = Day03.GetTreesHit(input, dx, dy);

            Assert.AreEqual(expected, actual, "Number of trees hit does not equal expected.");
        }
コード例 #6
0
 public void Task1()
 {
     Assert.AreEqual(0, Day03.Task1(1));
     Assert.AreEqual(3, Day03.Task1(12));
     Assert.AreEqual(2, Day03.Task1(23));
     Assert.AreEqual(31, Day03.Task1(1024));
 }
コード例 #7
0
        public void GetDay3Part2AnswerTest()
        {
            int expected = 20286;
            int actual   = Day03.GetDay3Part2Answer();

            Assert.Equal(expected, actual);
        }
コード例 #8
0
ファイル: Day03Tests.cs プロジェクト: peteski22/AdventOfCode
        public void ShouldGetCorrectNumberOfConflicts()
        {
            const int fabricSize = 1000;
            var       result     = Day03.GetNumberOfConflictsAndRemainingCleanClaims(path, fabricSize);

            Assert.AreEqual(104126, result.Item1);
        }
コード例 #9
0
    public void Day03(int part1, int part2)
    {
        var d = new Day03();

        Assert.Equal(part1.ToString(), d.Part1());
        Assert.Equal(part2.ToString(), d.Part2());
    }
コード例 #10
0
ファイル: Test03.cs プロジェクト: htoomik/aoc2019
        public void Part2(string w1, string w2, int expected)
        {
            var solver = new Day03();
            var result = solver.Solve2(w1, w2);

            result.ShouldBe(expected);
        }
コード例 #11
0
        public void RoboWalkThroughHouses(string directions, int expectedHouseCount)
        {
            var d03        = new Day03();
            var houseCount = d03.CountHousesWithPresent(directions, 2);

            Assert.That(houseCount, Is.EqualTo(expectedHouseCount));
        }
コード例 #12
0
        public void Day03()
        {
            var day = new Day03(289326);

            Assert.Equal(419, day.FirstPart());
            Assert.Equal(289326, day.SecondPart());
        }
コード例 #13
0
ファイル: Day03Test.cs プロジェクト: frangiz/AdventOfCode2016
 public void ExampleA1()
 {
     Assert.AreEqual(0, Day03.ValidTriangles(
                         new HorizontalParser(new List <string> {
         "5 10 25"
     })));
 }
コード例 #14
0
        public void GetDay03Part02AnswerTest()
        {
            int expected = 1206576000;
            int actual   = Day03.GetDay03Part02Answer();

            Assert.Equal(expected, actual);
        }
コード例 #15
0
        public void GetDay03Part01AnswerTest()
        {
            int expected = 171;
            int actual   = Day03.GetDay03Part01Answer();

            Assert.Equal(expected, actual);
        }
コード例 #16
0
ファイル: Test03.cs プロジェクト: htoomik/aoc2019
        public void Part2Solution()
        {
            var lines  = InputDataHelper.GetLines(3);
            var solver = new Day03();
            var result = solver.Solve2(lines[0], lines[1]);

            _testOutputHelper.WriteLine(result.ToString());
        }
コード例 #17
0
ファイル: Test03.cs プロジェクト: htoomik/aoc2020
        public void Solve2()
        {
            var map    = DataHelper.GetAllRows(3);
            var solver = new Day03();
            var result = solver.Solve2(map);

            Output.WriteLine(result.ToString());
        }
コード例 #18
0
        public void Part2_TestOne()
        {
            var lines = new List <string> {
                "#1 @ 1,3: 4x4", "#2 @ 3,1: 4x4", "#3 @ 5,5: 2x2"
            };

            Assert.AreEqual(3, Day03.GetResult(lines).NonOverlappingClaimId);
        }
コード例 #19
0
        public void Part1_TestOne()
        {
            var lines = new List <string> {
                "#1 @ 1,3: 4x4", "#2 @ 3,1: 4x4", "#3 @ 5,5: 2x2"
            };

            Assert.AreEqual(4, Day03.GetResult(lines).OverlappingCount);
        }
コード例 #20
0
ファイル: Day03Test.cs プロジェクト: emilekberg/adventofcode
    public void Part2()
    {
        var expected = 230;
        var day      = new Day03();
        var actual   = day.Part2(_input);

        Assert.Equal(expected, actual);
    }
コード例 #21
0
        public void NumberOfSteps_Test(string[] line1, string[] line2, int expected)
        {
            // Act
            var actual = Day03.NumberOfSteps(line1, line2);

            // Assert
            Assert.Equal(expected, actual);
        }
コード例 #22
0
ファイル: Day03Tests.cs プロジェクト: aethercowboy/advent
        public void Test03(int x, int y, int expected)
        {
            var lines  = data.Lines().ToList();
            var slope  = new Tuple <int, int>(x, y);
            var result = Day03.TreesEncountered(lines, slope);

            Assert.Equal(expected, result);
        }
コード例 #23
0
        public void Part02(int input, int expected)
        {
            // Act
            int actual = Day03.Part02(input);

            // Assert
            Assert.Equal(expected, actual);
        }
コード例 #24
0
        public void Day03Part02()
        {
            var day03 = new Day03();

            day03.Part02("1").Should().Be("2");
            day03.Part02("58").Should().Be("59");
            day03.Part02("59").Should().Be("122");
        }
コード例 #25
0
        public void TestPart2()
        {
            string[] input = new string[] { "#1 @ 1,3: 4x4", "#2 @ 3,1: 4x4", "#3 @ 5,5: 2x2" };

            Day03 day03 = new Day03();

            Assert.Equal(3, day03.Part2(day03.ParseClaims(input)));
        }
コード例 #26
0
        public void Day03_Part1_Examples()
        {
            var d = new Day03();

            Assert.AreEqual(2, d.SolutionPart1(">"));
            Assert.AreEqual(4, d.SolutionPart1("^>v<"));
            Assert.AreEqual(2, d.SolutionPart1("^v^v^v^v^v"));
        }
コード例 #27
0
    public static void Y2016_Day03_IsTriangleValid_Returns_Correct_Solution(int a, int b, int c, bool expected)
    {
        // Act
        bool actual = Day03.IsValidTriangle(a, b, c);

        // Assert
        actual.ShouldBe(expected);
    }
コード例 #28
0
        public void DrawLine_Test(string[] line1, string[] line2, int expected)
        {
            // Act
            var actual = Day03.Distance(line1, line2);

            // Assert
            Assert.Equal(expected, actual);
        }
コード例 #29
0
ファイル: Day03Tests.cs プロジェクト: peteski22/AdventOfCode
        public void ShouldGetTheOnlyConflictFreeId()
        {
            const int fabricSize = 1000;
            var       result     = Day03.GetNumberOfConflictsAndRemainingCleanClaims(path, fabricSize);

            Assert.AreEqual(1, result.Item2.Count);
            Assert.AreEqual("695", result.Item2.First());
        }
コード例 #30
0
    public void Day03_Extra(string code, int part1, int part2)
    {
        var d = new Day03();

        d.OverrideInput(code);
        Assert.Equal(part1.ToString(), d.Part1());
        Assert.Equal(part2.ToString(), d.Part2());
    }