示例#1
0
文件: Program.cs 项目: fluce/aoc19
        static void Main(string[] args)
        {
            var map = @"#.#....#.#......#.....#......####.
#....#....##...#..#..##....#.##..#
#.#..#....#..#....##...###......##
...........##..##..##.####.#......
...##..##....##.#.....#.##....#..#
..##.....#..#.......#.#.........##
...###..##.###.#..................
.##...###.#.#.......#.#...##..#.#.
...#...##....#....##.#.....#...#.#
..##........#.#...#..#...##...##..
..#.##.......#..#......#.....##..#
....###..#..#...###...#.###...#.##
..#........#....#.....##.....#.#.#
...#....#.....#..#...###........#.
.##...#........#.#...#...##.......
.#....#.#.#.#.....#...........#...
.......###.##...#..#.#....#..##..#
#..#..###.#.......##....##.#..#...
..##...#.#.#........##..#..#.#..#.
.#.##..#.......#.#.#.........##.##
...#.#.....#.#....###.#.........#.
.#..#.##...#......#......#..##....
.##....#.#......##...#....#.##..#.
#..#..#..#...........#......##...#
#....##...#......#.###.#..#.#...#.
#......#.#.#.#....###..##.##...##.
......#.......#.#.#.#...#...##....
....##..#.....#.......#....#...#..
.#........#....#...#.#..#....#....
.#.##.##..##.#.#####..........##..
..####...##.#.....##.............#
....##......#.#..#....###....##...
......#..#.#####.#................
.#....#.#..#.###....##.......##.#.";

            var field = new AsteroidField(map.Split(new char[] { '\n', '\r' }, 100, StringSplitOptions.RemoveEmptyEntries));

            var(cell, c) = field.GetMaxVisibilityCell();

            Console.WriteLine($"{cell.X} {cell.Y} => {c}");
            //field.Log=Console.WriteLine;
            //field.TraceVaporize=true;
            int i = 0;

            foreach (var asteroid in field.Vaporize(cell))
            {
                i++;
                if (i == 200)
                {
                    Console.WriteLine($"{i} Vaporized {asteroid.X},{asteroid.Y} => {asteroid.X*100+asteroid.Y}");
                }
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            var inputFile = Environment.CurrentDirectory + "//input.txt";

            string[] lines = System.IO.File.ReadAllLines(inputFile);

            AsteroidField field = new AsteroidField(lines);

            field.CalculateVisibleAsteroids();
            field.IdentifyMonitoringStation();
            field.BuildAsteroidDictFromMonitoringStation();
            field.ZapAsteroids();

            Console.WriteLine("Highest number of visible asteroids: " + field.HighestNumberOfVisibleAsteroids);
        }