Beispiel #1
0
        public void TobogganTrajectoryApplyRule(int[] expectedPosition, int[] initialPosition, int[] rule)
        {
            var tobogganTrajectory = new TobogganTrajectory("toboggan_testing_map.txt");
            var actualPosition     = tobogganTrajectory.ApplyRule(initialPosition, rule);

            Assert.AreEqual(expectedPosition, actualPosition);
        }
Beispiel #2
0
        public void TobogganTrajectoryParseMap()
        {
            var tobogganTrajectory = new TobogganTrajectory("toboggan_testing_map.txt");

            Assert.AreEqual(11, tobogganTrajectory.MapHeight);
            Assert.AreEqual(11, tobogganTrajectory.MapWidth);
        }
Beispiel #3
0
        public void TobogganTrajectoryCountTrees(int expectedCount, int[] rule)
        {
            var tobogganTrajectory = new TobogganTrajectory("toboggan_testing_map.txt");

            var trees = tobogganTrajectory.CountTrees(rule);

            Assert.AreEqual(expectedCount, trees);
        }
Beispiel #4
0
        public void CalculateNumberOfTrees_ShouldReturnTotalNumberOfHits_GivenProblemInputAndTrajectory3And1()
        {
            var map = File.ReadAllLines("Inputs\\day03.txt");
            var sut = new TobogganTrajectory();

            var actual = sut.CalculateNumberOfTrees(map, (3, 1));

            actual.Should().Be(195);
        }
Beispiel #5
0
        public void TobogganTrajectoryDetectTree()
        {
            var tobogganTrajectory = new TobogganTrajectory("toboggan_testing_map.txt");

            var actualPosition = tobogganTrajectory.ApplyRule(new[] { 0, 0 }, new[] { 0, 0, 1, 3 });

            Assert.IsFalse(tobogganTrajectory.IsTRee(actualPosition));

            actualPosition = tobogganTrajectory.ApplyRule(actualPosition, new[] { 0, 0, 1, 3 });
            Assert.IsTrue(tobogganTrajectory.IsTRee(actualPosition));
        }
Beispiel #6
0
        public void CalculateNumberOfTrees_ShouldReturnTotalNumberOfTrees_GivenSmallMap()
        {
            var map = new[]
            {
                "#.",
                ".#"
            };
            var sut = new TobogganTrajectory();

            var actual = sut.CalculateNumberOfTrees(map, (1, 1));

            actual.Should().Be(2);
        }
Beispiel #7
0
 public void CalculateNumberOfTrees_ShouldReturnTotalNumberOfTrees_GivenProblemInputAndMultipleTrajectories()
 {
     var map          = File.ReadAllLines("Inputs\\day03.txt");
     var sut          = new TobogganTrajectory();
     var trajectories = new[] { (1, 1), (3, 1), (5, 1), (7, 1), (1, 2) };