Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Archery_Tournament
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> targetList = Console.ReadLine()
- .Split("|")
- .Select(int.Parse)
- .ToList();
- int points = 0;
- while (true)
- {
- List<string> splitedInput = Console.ReadLine().Split('@').ToList();
- if (splitedInput[0] == "Game over")
- { break; }
- if (splitedInput[0] == "Reverse")
- { targetList.Reverse(); }
- else if (splitedInput[0]== "Shoot Left")
- {
- int startindex = int.Parse(splitedInput[1]);
- int shouted = int.Parse(splitedInput[2]);
- if (startindex > targetList.Count - 1)
- { continue; }
- targetList.Reverse();
- GetShoutedList(targetList, startindex, shouted);
- targetList.Reverse();
- points += 5;
- }
- else if (splitedInput[0] == "Shoot Right")
- {
- int startindex = int.Parse(splitedInput[1]);
- int shouted = int.Parse(splitedInput[2]);
- if (startindex > targetList.Count - 1)
- { continue; }
- // GetShoutedList(targetList, startindex, shouted);
- int targetListIndexLenght = targetList.Count;
- int forShout = startindex + shouted;
- if (targetListIndexLenght == shouted)
- {
- targetList[startindex] -= 5;
- }
- else if (forShout == targetListIndexLenght)
- {
- targetList[startindex] -= 5;
- }
- else if (forShout > targetListIndexLenght)
- {
- int left = forShout % targetListIndexLenght;
- if (left != 0)
- { targetList[left] -= 5; }
- else
- { targetList[startindex] -= 5; }
- }
- else if (forShout < targetListIndexLenght)
- { targetList[forShout - 1] -= 5; }
- points += 5;
- }
- }
- Console.WriteLine(String.Join(" - ",targetList));
- Console.WriteLine($"Iskren finished the archery tournament with {points} points!");
- }
- static List<int> GetShoutedList(List<int> targetList, int startindex, int shouted)
- {
- int targetListIndexLenght = targetList.Count;
- int forShout = startindex+ shouted;
- if (targetListIndexLenght == shouted)
- {
- targetList[startindex] -= 5;
- }
- else if (forShout == targetListIndexLenght)
- { targetList[startindex] -= 5;
- }
- else if (forShout > targetListIndexLenght)
- {
- int left = forShout % targetListIndexLenght;
- if (left != 0)
- { targetList[left-1] -= 5; }
- else
- { targetList[startindex] -= 5; }
- }
- else if(forShout<targetListIndexLenght)
- { targetList[forShout-1] -= 5; }
- return targetList;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement