Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Text.RegularExpressions;
- namespace Orders
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> turnament = Console.ReadLine().Split('|', StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList();
- string input = string.Empty;
- int points = 0;
- while ((input = Console.ReadLine()) != "Game over")
- {
- string[] array = input.Split(" ", StringSplitOptions.RemoveEmptyEntries);
- string command = array[0];
- //Console.WriteLine(command);
- if (command == "Shoot")
- {
- string[] arrayNew = array[1].Split('@', StringSplitOptions.RemoveEmptyEntries);
- string direction = arrayNew[0];
- int startIndex = int.Parse(arrayNew[1]);
- int length = int.Parse(arrayNew[2]);
- if (startIndex <= turnament.Count && startIndex >= 0 && length >= 0)
- {
- if (length > turnament.Count)
- {
- int indexLenght = length % turnament.Count;
- length = indexLenght;
- }
- if (direction == "Left")
- {
- if (startIndex <= length)
- {
- int index = turnament.Count - length + startIndex;
- if(index == turnament.Count)
- {
- index = turnament.Count - 1;
- }
- if (turnament[index] >= 5)
- {
- turnament[index] -= 5;
- points += 5;
- }
- else if (turnament[index] > 0)
- {
- int number = turnament[index];
- points += number;
- turnament[index] = 0;
- }
- }
- else
- {
- if (turnament[startIndex - length] >= 5)
- {
- turnament[startIndex - length] -= 5;
- points += 5;
- }
- else if (turnament[startIndex - length] > 0)
- {
- int number = turnament[startIndex - length];
- points += number;
- turnament[startIndex - length] = 0;
- }
- }
- }
- else if (direction == "Right")
- {
- if (length + startIndex >= turnament.Count)
- {
- startIndex = (length + startIndex) - turnament.Count;
- if (turnament[startIndex] >= 5)
- {
- turnament[startIndex] -= 5;
- points += 5;
- }
- else
- {
- int number = turnament[startIndex];
- points += number;
- turnament[startIndex] = 0;
- }
- }
- else
- {
- if (turnament[startIndex - length] >= 5)
- {
- turnament[startIndex - length] -= 5;
- points += 5;
- }
- else
- {
- int number = turnament[startIndex - length];
- points += number;
- turnament[startIndex - length] = 0;
- }
- }
- }
- }
- }
- else if (command == "Reverse")
- {
- turnament.Reverse();
- }
- }
- Console.WriteLine(string.Join(" - ", turnament));
- Console.WriteLine($"Iskren finished the archery tournament with {points} points!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement