コード例 #1
0
        public void TestTreeCounterMultiSlope()
        {
            MapTraverser traverser = new MapTraverser();

            char[,] map = traverser.GetInputDataMap(TestDataFilePath);
            int noOfTrees = traverser.TreeCounterMultiSlope(map, this.slopes);

            Assert.AreEqual(336, noOfTrees);
        }
コード例 #2
0
        public void TestTreeCounter(int right, int down, int expectedTrees)
        {
            MapTraverser traverser = new MapTraverser();

            char[,] map = traverser.GetInputDataMap(TestDataFilePath);
            int noOfTrees = traverser.TreeCounter(map, right, down);

            Assert.AreEqual(expectedTrees, noOfTrees);
        }
コード例 #3
0
        public void TestGetInputData()
        {
            MapTraverser traverser = new MapTraverser();

            char[,] map = traverser.GetInputDataMap(PuzzleFilePath);
            Assert.AreEqual(323, map.GetLength(0));
            Assert.AreEqual(31, map.GetLength(1));
            Assert.AreEqual('.', map[0, 0]);
        }
コード例 #4
0
        public void SolveDayThreePuzzelTwo()
        {
            var          watch     = System.Diagnostics.Stopwatch.StartNew();
            MapTraverser traverser = new MapTraverser();

            char[,] map = traverser.GetInputDataMap(PuzzleFilePath);
            int noOfTrees = traverser.TreeCounterMultiSlope(map, this.slopes);

            watch.Stop();
            Console.WriteLine($"Execution Time: {watch.ElapsedMilliseconds} ms");
            Assert.AreEqual(1115775000, noOfTrees);
        }
コード例 #5
0
        public void SolveDayThreePuzzelOne()
        {
            MapTraverser traverser = new MapTraverser();
            int          down      = 1;
            int          right     = 3;

            char[,] map = traverser.GetInputDataMap(PuzzleFilePath);
            int noOfTrees = traverser.TreeCounter(map, right, down);

            Console.WriteLine(noOfTrees);
            Assert.AreEqual(225, noOfTrees);
        }