Esempio n. 1
0
        static void Main(string[] args)
        {
            var move = new Point(3, 1);
            var map  = new HorizontalTilingMap();

            map.LoadMapFile(@"C:\Dev\GitHub\AdventOfCode2020\Day3\Data\input");
            var run = new TobogganRun(map);

            var possibleRuns = new Point[]
            {
                new Point(1, 1),
                new Point(3, 1),
                new Point(5, 1),
                new Point(7, 1),
                new Point(1, 2)
            };

            var currentProduct = 1;

            foreach (var possibleRun in possibleRuns)
            {
                var treeCount = run.TreeCount(possibleRun);
                currentProduct *= treeCount;
                Console.WriteLine($"Move: {possibleRun}\tTrees: {treeCount}");
            }

            Console.WriteLine(currentProduct);
        }
        public void TreeCount_ValidMoveFromArbitraryPoint_ReturnsExpectedValue(int moveX, int moveY, int startX, int startY, int expectedTrees)
        {
            var map = new HorizontalTilingMap();

            map.LoadMap(@"..##.......
#...#...#..
.#....#..#.
..#.#...#.#
.#...##..#.
..#.##.....
.#.#.#....#
.#........#
#.##...#...
#...##....#
.#..#...#.#");

            var move  = new Point(moveX, moveY);
            var start = new Point(startX, startY);
            var sut   = new sut.TobogganRun(map);

            var result = sut.TreeCount(move, start);

            Assert.Equal(expectedTrees, result);
        }