Esempio n. 1
0
        static void Main(string[] args)
        {
            var lines = File.ReadAllLines("input.txt");
            //part1
            //var lines = new string[]  {"COM)B","B)C","C)D","D)E","E)F","B)G","G)H","D)I","E)J","J)K","K)L" };
            //part2
            //var lines = new string[] { "COM)B","B)C","C)D","D)E","E)F","B)G","G)H","D)I","E)J","J)K","K)L","K)YOU","I)SAN"};
            var counter = new TreeCounter();


            Console.WriteLine("Answer: " + counter.CountOrbits(lines));
            Console.ReadLine();
        }
Esempio n. 2
0
        public void Then_all_the_encountered_trees_are_counted(string input, int right, int down, int expectedResult)
        {
            var mockPuzzleInput = new Mock <IPuzzleInput>();

            mockPuzzleInput.Setup(p => p.GetPuzzleInputAsArray(It.IsAny <string>())).Returns(input.Split('|'));

            var map = new Map(mockPuzzleInput.Object);

            var sut = new TreeCounter(map);

            var result = sut.Run(right, down);

            Assert.That(result, Is.EqualTo(expectedResult));
        }
Esempio n. 3
0
        public ThreadManager(int dimension)
        {
            allThreadsHandlers = new HandlerThread[Environment.ProcessorCount];
            for (int i = 0; i < allThreadsHandlers.Length; i++)
            {
                allThreadsHandlers[i] = new HandlerThread();
            }

            this.dimension = dimension;
            trees          = new TreeList();
            treeEtor       = trees.GetEnumerator();

            sw       = new Stopwatch();
            AllTrees = TreeCounter.NumOfTrees(1 << dimension);
        }
Esempio n. 4
0
        public void ExampleOne()
        {
            var map = new List <string>
            {
                "..##.......",
                "#...#...#..",
                ".#....#..#.",
                "..#.#...#.#",
                ".#...##..#.",
                "..#.##.....",
                ".#.#.#....#",
                ".#........#",
                "#.##...#...",
                "#...##....#",
                ".#..#...#.#"
            };

            var treeCounter = new TreeCounter(map);
            var actual      = treeCounter.MultiplyTreeCountForAllSlopes();

            actual.Should().Be(336);
        }
        public void ExampleOne()
        {
            var map = new List <string>
            {
                "..##.......",
                "#...#...#..",
                ".#....#..#.",
                "..#.#...#.#",
                ".#...##..#.",
                "..#.##.....",
                ".#.#.#....#",
                ".#........#",
                "#.##...#...",
                "#...##....#",
                ".#..#...#.#"
            };

            var treeCounter = new TreeCounter(map);
            var actual      = treeCounter.GetTreeCountForDefinedSlope();

            actual.Should().Be(7);
        }