Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace Archery_Tournament
- {
- class Program
- {
- static void Main()
- {
- List<int> targets = Console.ReadLine()
- .Split("|")
- .Select(int.Parse)
- .ToList();
- string input;
- int points = 0;
- while ((input=Console.ReadLine())!="Game over")
- {
- string[] cmdArgs = input.Split("@").ToArray();
- string command = cmdArgs[0];
- if (command=="Shoot Left")
- {
- if (int.Parse(cmdArgs[1]) < targets.Count() && int.Parse(cmdArgs[1]) >= 0)
- {
- int startIndex = int.Parse(cmdArgs[1]);
- int length = int.Parse(cmdArgs[2]);
- for (int i = 0; i < length; i--)
- {
- startIndex--;
- if (startIndex < 0)
- {
- startIndex = targets.Count() - 1;
- }
- }
- if (targets[startIndex] < 5)
- {
- points += targets[startIndex];
- targets[startIndex] = 0;
- }
- else
- {
- points += 5;
- targets[startIndex] -= 5;
- }
- }
- else
- {
- }
- }
- else if (command=="Shoot Right")
- {
- if (int.Parse(cmdArgs[1]) < targets.Count() && int.Parse(cmdArgs[1]) >= 0)
- {
- int startIndex = int.Parse(cmdArgs[1]);
- int length = int.Parse(cmdArgs[2]);
- for (int i = 0; i < length; i--)
- {
- startIndex++;
- if (startIndex > targets.Count() - 1)
- {
- startIndex = 0;
- }
- }
- if (targets[startIndex] < 5)
- {
- points += targets[startIndex];
- targets[startIndex] = 0;
- }
- else
- {
- points += 5;
- targets[startIndex] -= 5;
- }
- }
- else
- {
- }
- }
- else if (command=="Reverse")
- {
- targets.Reverse();
- }
- }
- for (int i = 0; i < targets.Count(); i++)
- {
- if (targets[i]==targets.Count()-1)
- {
- Console.WriteLine($"{targets[i]}");
- }
- else
- {
- Console.WriteLine($"{targets[i]}-");
- }
- }
- Console.WriteLine();
- Console.WriteLine($"Iskren finished the archery tournament with {points}!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement