Example #1
0
        private static void UpdateCoordinates(string command, Ivo ivo, Evil evil)
        {
            var ivoCoordinates = command.Split(' ', StringSplitOptions.RemoveEmptyEntries)
                                 .Select(int.Parse).ToArray();

            ivo.UpdateCoordinates(ivoCoordinates[0], ivoCoordinates[1]);

            command = Console.ReadLine();

            var evilCoordinates = command.Split(' ', StringSplitOptions.RemoveEmptyEntries)
                                  .Select(int.Parse).ToArray();

            evil.UpdateCoordinates(evilCoordinates[0], evilCoordinates[1]);
        }
Example #2
0
        private static void MoveIvo(Ivo ivo, int[,] matrix)
        {
            int n = matrix.GetLength(0);
            int m = matrix.GetLength(1);

            while (ivo.Row >= 0)
            {
                if (ivo.Row < n && ivo.Col >= 0 && ivo.Col < m)
                {
                    ivo.CollectPoints(matrix[ivo.Row, ivo.Col]);
                }

                ivo.UpdateCoordinates(ivo.Row - 1, ivo.Col + 1);
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            short[] sizes = Console.ReadLine()
                            .Split(' ', StringSplitOptions.RemoveEmptyEntries)
                            .Select(short.Parse)
                            .ToArray();

            var matrix = InitializeMatrix(sizes);
            var ivo    = new Ivo();
            var evil   = new Evil();

            string command;

            while ((command = Console.ReadLine()) != "Let the Force be with you")
            {
                UpdateCoordinates(command, ivo, evil);
                MoveEvil(evil, matrix);
                MoveIvo(ivo, matrix);
            }

            Console.WriteLine(ivo.Score);

            Console.ReadKey();
        }