Ejemplo n.º 1
0
        public static void Run()
        {
            AsteroidMap map = AsteroidMapFactory.CreateAsteroidMap("10");

            Console.WriteLine("Result part1: {0}", map.MaxNumberOfVisibleAsteroids());
            Console.WriteLine("Result part2: {0}", map.AsteroidVaporizedAt200());
        }
        public static AsteroidMap CreateAsteroidMap(string file)
        {
            AsteroidMap asteroidMap = new AsteroidMap();

            string[] lines  = System.IO.File.ReadAllLines(DataHelper.getPath(file));
            int      width  = lines[0].Length;
            int      height = lines.Length;

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    if (lines[y][x] == '#')
                    {
                        asteroidMap.Add(new Asteroid(x, y));
                    }
                }
            }
            return(asteroidMap);
        }