Beispiel #1
0
        public static string Run(string input)
        {
            var sr = new StringReader(input);
            var gridMaxString = sr.ReadLine();

            Parser parser = new Parser();
            var gridMax = parser.MaxPosition(gridMaxString);

            var output = new StringBuilder();

            for (; ; )
            {
                var startAsString = sr.ReadLine();
                var movementsAsString = sr.ReadLine();
                if (string.IsNullOrEmpty(startAsString) || string.IsNullOrEmpty(movementsAsString))
                {
                    break;
                }

                var start = parser.Start(startAsString);
                var movements = parser.Movements(movementsAsString);
                var rover = new Rover(start.Position, start.Direction);
                rover = movements(rover);
                output.AppendFormat("{0}{1}", rover, Environment.NewLine);
            }

            return output.ToString();
        }