Advertisement
gospod1978

New paste

Dec 10th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.08 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Text.RegularExpressions;
  8.  
  9.  
  10. namespace Orders
  11. {
  12.     class Program
  13.     {
  14.         static void Main(string[] args)
  15.         {
  16.             List<int> turnament = Console.ReadLine().Split('|', StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList();
  17.  
  18.             string input = string.Empty;
  19.             int points = 0;
  20.  
  21.             while ((input = Console.ReadLine()) != "Game over")
  22.             {
  23.                 string[] array = input.Split(" ", StringSplitOptions.RemoveEmptyEntries);
  24.  
  25.                 string command = array[0];
  26.                 //Console.WriteLine(command);
  27.  
  28.  
  29.                 if (command == "Shoot")
  30.                 {
  31.                     string[] arrayNew = array[1].Split('@', StringSplitOptions.RemoveEmptyEntries);
  32.                     string direction = arrayNew[0];
  33.                     int startIndex = int.Parse(arrayNew[1]);
  34.                     int length = int.Parse(arrayNew[2]);
  35.  
  36.                     if (startIndex <= turnament.Count && startIndex >= 0 && length >= 0)
  37.                     {
  38.                         if (length > turnament.Count)
  39.                         {
  40.                             int indexLenght = length % turnament.Count;
  41.                             length = indexLenght;
  42.                         }
  43.  
  44.  
  45.                         if (direction == "Left")
  46.                         {
  47.  
  48.                             if (startIndex <= length)
  49.                             {
  50.                                 int index = turnament.Count - length + startIndex;
  51.                                 if(index == turnament.Count)
  52.                                 {
  53.                                     index = turnament.Count - 1;
  54.                                 }
  55.                                 if (turnament[index] >= 5)
  56.                                 {
  57.                                     turnament[index] -= 5;
  58.                                     points += 5;
  59.                                 }
  60.                                 else if (turnament[index] > 0)
  61.                                 {
  62.                                     int number = turnament[index];
  63.                                     points += number;
  64.                                     turnament[index] = 0;
  65.                                 }
  66.                             }
  67.                             else
  68.                             {
  69.                                 if (turnament[startIndex - length] >= 5)
  70.                                 {
  71.                                     turnament[startIndex - length] -= 5;
  72.                                     points += 5;
  73.                                 }
  74.                                 else if (turnament[startIndex - length] > 0)
  75.                                 {
  76.                                     int number = turnament[startIndex - length];
  77.                                     points += number;
  78.                                     turnament[startIndex - length] = 0;
  79.                                 }
  80.                             }
  81.  
  82.                         }
  83.                         else if (direction == "Right")
  84.                         {
  85.  
  86.  
  87.                             if (length + startIndex >= turnament.Count)
  88.                             {
  89.                                 startIndex = (length + startIndex) - turnament.Count;
  90.  
  91.                                 if (turnament[startIndex] >= 5)
  92.                                 {
  93.                                     turnament[startIndex] -= 5;
  94.                                     points += 5;
  95.                                 }
  96.                                 else
  97.                                 {
  98.                                     int number = turnament[startIndex];
  99.                                     points += number;
  100.                                     turnament[startIndex] = 0;
  101.                                 }
  102.                             }
  103.                             else
  104.                             {
  105.                                 if (turnament[startIndex - length] >= 5)
  106.                                 {
  107.                                     turnament[startIndex - length] -= 5;
  108.                                     points += 5;
  109.                                 }
  110.                                 else
  111.                                 {
  112.                                     int number = turnament[startIndex - length];
  113.                                     points += number;
  114.                                     turnament[startIndex - length] = 0;
  115.                                 }
  116.                             }
  117.  
  118.                         }
  119.                     }
  120.  
  121.                    
  122.                 }
  123.                 else if (command == "Reverse")
  124.                 {
  125.                     turnament.Reverse();
  126.                 }
  127.             }
  128.  
  129.             Console.WriteLine(string.Join(" - ", turnament));
  130.             Console.WriteLine($"Iskren finished the archery tournament with {points} points!");
  131.         }
  132.     }
  133.  
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement