Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication7
- {
- class Program
- {
- static void Main(string[] args)
- {
- char[] firstLine = Console.ReadLine().ToArray();
- char[] secondLine = Console.ReadLine().ToArray();
- char[] thirdLine = Console.ReadLine().ToArray();
- char[] fourthLine = Console.ReadLine().ToArray();
- char[] input = Console.ReadLine().ToArray();
- char[][] jagged = new char[4][] { firstLine, secondLine, thirdLine, fourthLine };
- int currentRow = 0;
- int currentCol = 0;
- int coinsCounter = 0;
- int wallsCounter = 0;
- for (int i = 0; i < input.Length; i++)
- {
- if (input[i] == 'V')
- {
- //if V
- if (currentRow == 0)
- {
- if (currentCol < secondLine.Length)
- {
- currentRow++;
- if (jagged[currentRow][currentCol] == '$')
- {
- coinsCounter++;
- }
- continue;
- }
- else
- {
- wallsCounter++;
- continue;
- }
- }
- if (currentRow == 1)
- {
- if (currentCol < thirdLine.Length)
- {
- currentRow++;
- if (jagged[currentRow][currentCol] == '$')
- {
- coinsCounter++;
- }
- continue;
- }
- else
- {
- wallsCounter++;
- continue;
- }
- }
- if (currentRow == 2)
- {
- if (currentCol < fourthLine.Length)
- {
- currentRow++;
- if (jagged[currentRow][currentCol] == '$')
- {
- coinsCounter++;
- }
- continue;
- }
- else
- {
- wallsCounter++;
- continue;
- }
- }
- if (currentRow == 3)
- {
- wallsCounter++;
- continue;
- }
- }//if = V/
- //if >
- if (input[i] == '>')
- {
- if (currentRow == 0)
- {
- if (currentCol < firstLine.Length)
- {
- currentCol++;
- if (jagged[currentRow][currentCol] == '$')
- {
- coinsCounter++;
- }
- continue;
- }
- else
- {
- wallsCounter++;
- continue;
- }
- }
- if (currentRow == 1)
- {
- if (currentCol < secondLine.Length)
- {
- currentCol++;
- if (jagged[currentRow][currentCol] == '$')
- {
- coinsCounter++;
- }
- continue;
- }
- else
- {
- wallsCounter++;
- continue;
- }
- }
- if (currentRow == 2)
- {
- if (currentCol < thirdLine.Length)
- {
- currentCol++;
- if (jagged[currentRow][currentCol] == '$')
- {
- coinsCounter++;
- }
- continue;
- }
- else
- {
- wallsCounter++;
- continue;
- }
- }
- if (currentRow == 3)
- {
- if (currentCol < fourthLine.Length)
- {
- currentCol++;
- if (jagged[currentRow][currentCol] == '$')
- {
- coinsCounter++;
- }
- continue;
- }
- else
- {
- wallsCounter++;
- continue;
- }
- }
- }
- //if >/
- //if <
- if (input[i] == '<')
- {
- if (currentCol != 0)
- {
- currentCol--;
- if (jagged[currentRow][currentCol] == '$')
- {
- coinsCounter++;
- }
- continue;
- }
- else
- {
- wallsCounter++;
- continue;
- }
- }//if </
- if (input[i] == '^')
- {
- if (currentRow == 0)
- {
- wallsCounter++;
- continue;
- }
- if (currentRow == 3)
- {
- if (currentCol < thirdLine.Length)
- {
- currentRow--;
- if (jagged[currentRow][currentCol] == '$')
- {
- coinsCounter++;
- }
- continue;
- }
- else
- {
- wallsCounter++;
- continue;
- }
- }
- if (currentRow == 2)
- {
- if (currentCol < secondLine.Length)
- {
- currentRow--;
- if (jagged[currentRow][currentCol] == '$')
- {
- coinsCounter++;
- }
- continue;
- }
- else
- {
- wallsCounter++;
- continue;
- }
- }
- if (currentRow == 1)
- {
- if (currentCol < firstLine.Length)
- {
- currentRow--;
- if (jagged[currentRow][currentCol] == '$')
- {
- coinsCounter++;
- }
- continue;
- }
- else
- {
- wallsCounter++;
- continue;
- }
- }
- }
- }//enf for
- Console.WriteLine("Coins collected:");
- Console.WriteLine(coinsCounter);
- Console.WriteLine("Walls hit:");
- Console.WriteLine(wallsCounter);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment