예제 #1
0
        static void Main()
        {
            int[] dimestions = Console.ReadLine()
                               .Split(" ", StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
            int rows = dimestions[0];
            int cols = dimestions[1];

            Board board = new Board(rows, cols);

            string command = Console.ReadLine();

            long sum = 0;

            while (command != "Let the Force be with you")
            {
                int[] playerCoordinates = command
                                          .Split(" ", StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();

                int[] evilCoordinates = Console.ReadLine()
                                        .Split(" ", StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();


                Player evil = new Player();
                {
                    evil.Row = evilCoordinates[0];
                    evil.Col = evilCoordinates[1];
                };

                while (evil.Row >= 0 && evil.Col >= 0)
                {
                    if (board.IsInside(evil.Row, evil.Col))
                    {
                        board.Matrix[evil.Row, evil.Col] = 0;
                    }
                    evil.Row--;
                    evil.Col--;
                }

                Player player = new Player();
                {
                    player.Row = playerCoordinates[0];
                    player.Col = playerCoordinates[1];
                };

                while (player.Row >= 0 && player.Col < board.Matrix.GetLength(1))
                {
                    if (board.IsInside(player.Row, player.Col))
                    {
                        sum += board.Matrix[player.Row, player.Col];
                    }

                    player.Row++;
                    player.Col--;
                }

                command = Console.ReadLine();
            }

            Console.WriteLine(sum);
        }
        static void Main()
        {
            int[] dimestions = Console.ReadLine().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
            int   rows       = dimestions[0];
            int   cols       = dimestions[1];

            var board = new Board(rows, cols);

            string command = Console.ReadLine();
            long   sum     = 0;

            while (command != "Let the Force be with you")
            {
                int[] ivoArgs  = command.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
                int[] evilArgs = Console.ReadLine().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();

                int evilRow = evilArgs[0];
                int evilCol = evilArgs[1];
                var evil    = new Entity(evilRow, evilCol);


                while (evil.Row >= 0 && evil.Col >= 0)
                {
                    if (board.IsInside(evil.Row, evil.Col))
                    {
                        board.Matrix[evil.Row, evil.Col] = 0;
                    }

                    evil.Row--;
                    evil.Col--;
                }

                int ivoRow = ivoArgs[0];
                int ivoCol = ivoArgs[1];
                var ivo    = new Entity(ivoRow, ivoCol);

                while (ivo.Row >= 0 && ivo.Col < board.Matrix.GetLength(1))
                {
                    if (board.IsInside(ivo.Row, ivo.Col))
                    {
                        sum += board.Matrix[ivo.Row, ivo.Col];
                    }

                    ivo.Row--;
                    ivo.Col++;
                }

                command = Console.ReadLine();
            }

            Console.WriteLine(sum);
        }
예제 #3
0
        static void Main()
        {
            int[] dimensions = ParseInputToArray(Console.ReadLine());
            int   rows       = dimensions[0];
            int   cols       = dimensions[1];

            Board board = new Board(rows, cols);

            string command = Console.ReadLine();
            long   sum     = 0;

            while (command != "Let the Force be with you")
            {
                int[] playerCoordinates = ParseInputToArray(command);
                int[] evilCoordinates   = ParseInputToArray(Console.ReadLine());

                Player evil = new Player(evilCoordinates[0], evilCoordinates[1]);

                while (evil.Row >= 0 && evil.Col >= 0)
                {
                    if (board.IsInside(evil.Row, evil.Col))
                    {
                        board.Matrix[evil.Row, evil.Col] = 0;
                    }
                    evil.Row--;
                    evil.Col--;
                }

                Player player = new Player(playerCoordinates[0], playerCoordinates[1]);

                while (player.Row >= 0 && player.Col < board.Matrix.GetLength(1))
                {
                    if (board.IsInside(player.Row, player.Col))
                    {
                        sum += board.Matrix[player.Row, player.Col];
                    }

                    player.Col++;
                    player.Row--;
                }

                command = Console.ReadLine();
            }

            Console.WriteLine(sum);
        }
예제 #4
0
        public static void Main()
        {
            int[] sizes = GetCordinats(Console.ReadLine());

            Board field = new Board(sizes[0], sizes[1]);

            long sum = 0;

            string command;

            while ((command = Console.ReadLine()) != "Let the Force be with you")
            {
                int[] startEvil = GetCordinats(Console.ReadLine());

                Player evil = new Player(startEvil[0], startEvil[1]);

                while (evil.Row >= 0 && evil.Col >= 0)
                {
                    if (field.IsInside(evil.Row, evil.Col))
                    {
                        field.Matrix[evil.Row, evil.Col] = 0;
                    }

                    evil.Row--;
                    evil.Col--;
                }

                int[] startPlayer = GetCordinats(command);

                Player player = new Player(startPlayer[0], startPlayer[1]);

                while (player.Row >= 0 && player.Col < field.Matrix.GetLength(1))
                {
                    if (field.IsInside(player.Row, player.Col))
                    {
                        sum += field.Matrix[player.Row, player.Col];
                    }

                    player.Col++;
                    player.Row--;
                }
            }

            Console.WriteLine(sum);
        }
예제 #5
0
        public static void Main()
        {
            int[] dimensions = Console.ReadLine()
                               .Split(new string[] { " " }
                                      , StringSplitOptions.RemoveEmptyEntries)
                               .Select(int.Parse)
                               .ToArray();

            int rows = dimensions[0];
            int cols = dimensions[1];

            var board = new Board(rows, cols);

            string command   = Console.ReadLine();
            long   ivoPoints = 0;

            while (command != "Let the Force be with you")
            {
                int[] ivoCoordinates = command
                                       .Split(new string[] { " " }
                                              , StringSplitOptions.RemoveEmptyEntries)
                                       .Select(int.Parse)
                                       .ToArray();

                var ivo = new Player();
                ivo.Row = ivoCoordinates[0];
                ivo.Col = ivoCoordinates[1];

                int[] evilCoordinates = Console.ReadLine()
                                        .Split(new string[] { " " }
                                               , StringSplitOptions.RemoveEmptyEntries)
                                        .Select(int.Parse)
                                        .ToArray();

                var evil = new Player();
                evil.Row = evilCoordinates[0];
                evil.Col = evilCoordinates[1];

                while (evil.Row >= 0 && evil.Col >= 0)
                {
                    if (board.IsInside(evil.Row, evil.Col))
                    {
                        board.Matrix[evil.Row, evil.Col] = 0;
                    }

                    evil.Row--;
                    evil.Col--;
                }

                while (ivo.Row >= 0 && ivo.Col < board.Matrix.GetLength(1))
                {
                    if (board.IsInside(ivo.Row, ivo.Col))
                    {
                        ivoPoints += board.Matrix[ivo.Row, ivo.Col];
                    }

                    ivo.Col++;
                    ivo.Row--;
                }

                command = Console.ReadLine();
            }

            Console.WriteLine(ivoPoints);
        }