コード例 #1
0
        public void AOC_2020_Day03a()
        {
            var input  = File.ReadAllText(".//Content2//2020/Day03.txt");
            var answer = AOC_2020_Day03_Answer.CountTrees(input);

            answer.Should().Be(198);
        }
コード例 #2
0
        public void test_tree_count_variable_slope(int deltaX, int deltaY, int expectedResult)
        {
            var input  = $"..##.......{Environment.NewLine}#...#...#..{Environment.NewLine}.#....#..#.{Environment.NewLine}..#.#...#.#{Environment.NewLine}.#...##..#.{Environment.NewLine}..#.##.....{Environment.NewLine}.#.#.#....#{Environment.NewLine}.#........#{Environment.NewLine}#.##...#...{Environment.NewLine}#...##....#{Environment.NewLine}.#..#...#.#";
            var answer = AOC_2020_Day03_Answer.CountTreesForSlopeX(input, deltaX, deltaY);

            answer.Should().Be(expectedResult);
        }
コード例 #3
0
        public void test_tree_count()
        {
            var input  = $"..##.......{Environment.NewLine}#...#...#..{Environment.NewLine}.#....#..#.{Environment.NewLine}..#.#...#.#{Environment.NewLine}.#...##..#.{Environment.NewLine}..#.##.....{Environment.NewLine}.#.#.#....#{Environment.NewLine}.#........#{Environment.NewLine}#.##...#...{Environment.NewLine}#...##....#{Environment.NewLine}.#..#...#.#";
            var answer = AOC_2020_Day03_Answer.CountTrees(input);

            answer.Should().Be(7);
        }
コード例 #4
0
        public void AOC_2020_Day03b()
        {
            var input   = File.ReadAllText(".//Content2//2020/Day03.txt");
            var answers = new[]
            {
                AOC_2020_Day03_Answer.CountTreesForSlopeX(input, 1, 1),
                AOC_2020_Day03_Answer.CountTreesForSlopeX(input, 3, 1),
                AOC_2020_Day03_Answer.CountTreesForSlopeX(input, 5, 1),
                AOC_2020_Day03_Answer.CountTreesForSlopeX(input, 7, 1),
                AOC_2020_Day03_Answer.CountTreesForSlopeX(input, 1, 2)
            };
            var answer = answers.Aggregate(1D, (acc, x) => acc * x);

            answer.Should().Be(5140884672);
        }