示例#1
0
        public static void Run()
        {
            List <Moon> moons = new List <Moon>();

            string[] lines = System.IO.File.ReadAllLines(DataHelper.getPath("12"));
            foreach (string orbit in lines)
            {
                Regex rx    = new Regex(@"^<x=(-?\d+), y=(-?\d+), z=(-?\d+)>$");
                var   match = rx.Match(orbit);
                int   x     = int.Parse(match.Groups[1].Value);
                int   y     = int.Parse(match.Groups[2].Value);
                int   z     = int.Parse(match.Groups[3].Value);
                moons.Add(new Moon(x, y, z));
            }

            Universe universe = new Universe();

            foreach (Moon m in moons)
            {
                universe.AddMoon(m);
            }
            universe.Run();
        }