示例#1
0
        public void TestScore(int x, int y, int expectedScore)
        {
            var map = new List <List <char> >
            {
                new List <char> {
                    '.', '#', '.', '.', '#'
                },
                new List <char> {
                    '.', '.', '.', '.', '.'
                },
                new List <char> {
                    '#', '#', '#', '#', '#'
                },
                new List <char> {
                    '.', '.', '.', '.', '#'
                },
                new List <char> {
                    '.', '.', '.', '#', '#'
                },
            };

            var testObject = new AsteroidsMonitoringSystem(map);

            var score = testObject.GetScore(new Extension.Mathematics.VectorSpace.IntVector(x, y));

            Assert.IsTrue(score == expectedScore);
        }
示例#2
0
        public void TestMap(List <List <char> > map, int expectedX, int expectedY, int expectedScore)
        {
            var testObject = new AsteroidsMonitoringSystem(map);

            var(position, score) = testObject.GetBestPosition();

            Assert.IsTrue(position.X == expectedX);
            Assert.IsTrue(position.Y == expectedY);
            Assert.IsTrue(score == expectedScore);
        }
示例#3
0
        /// <summary>
        /// Execution function for Day 10
        /// </summary>
        public void Execute10()
        {
            UserActionAsync(() =>
            {
                WriteToConsole("Start execution of Day10");
                var parser = GetInputParser("Day10Input.txt");
                var input  = parser.GetInputData();
                var map    = input.Select(s => s.ToCharArray().ToList()).ToList();

                var system           = new AsteroidsMonitoringSystem(map);
                var(position, score) = system.GetBestPosition();

                WriteToConsole($"The best position for the monitoring system is ({position.X}, {position.Y}) with a score of {score}");

                var sequence = system.GetVaporizationSequence(position);
                var destroy  = sequence[199];

                WriteToConsole($"The asteroid which is destroy at position 200 is at ({destroy.X}, {destroy.Y})");
            });
        }