Advertisement
AnastasiyaG

Untitled

Feb 23rd, 2020
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.75 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Archery_Tournament
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. List<int> targetList = Console.ReadLine()
  12. .Split("|")
  13. .Select(int.Parse)
  14. .ToList();
  15. int points = 0;
  16. while (true)
  17. {
  18. List<string> splitedInput = Console.ReadLine().Split('@').ToList();
  19.  
  20. if (splitedInput[0] == "Game over")
  21. { break; }
  22. if (splitedInput[0] == "Reverse")
  23. { targetList.Reverse(); }
  24.  
  25.  
  26.  
  27.  
  28.  
  29. else if (splitedInput[0]== "Shoot Left")
  30. {
  31. int startindex = int.Parse(splitedInput[1]);
  32. int shouted = int.Parse(splitedInput[2]);
  33.  
  34. if (startindex > targetList.Count - 1)
  35. { continue; }
  36. targetList.Reverse();
  37. GetShoutedList(targetList, startindex, shouted);
  38. targetList.Reverse();
  39. points += 5;
  40. }
  41. else if (splitedInput[0] == "Shoot Right")
  42. {
  43. int startindex = int.Parse(splitedInput[1]);
  44. int shouted = int.Parse(splitedInput[2]);
  45.  
  46. if (startindex > targetList.Count - 1)
  47. { continue; }
  48.  
  49. // GetShoutedList(targetList, startindex, shouted);
  50. int targetListIndexLenght = targetList.Count;
  51. int forShout = startindex + shouted;
  52.  
  53. if (targetListIndexLenght == shouted)
  54. {
  55. targetList[startindex] -= 5;
  56.  
  57. }
  58.  
  59. else if (forShout == targetListIndexLenght)
  60. {
  61. targetList[startindex] -= 5;
  62. }
  63. else if (forShout > targetListIndexLenght)
  64. {
  65. int left = forShout % targetListIndexLenght;
  66. if (left != 0)
  67. { targetList[left] -= 5; }
  68. else
  69. { targetList[startindex] -= 5; }
  70. }
  71. else if (forShout < targetListIndexLenght)
  72. { targetList[forShout - 1] -= 5; }
  73. points += 5;
  74.  
  75. }
  76. }
  77.  
  78. Console.WriteLine(String.Join(" - ",targetList));
  79. Console.WriteLine($"Iskren finished the archery tournament with {points} points!");
  80. }
  81.  
  82.  
  83. static List<int> GetShoutedList(List<int> targetList, int startindex, int shouted)
  84. {
  85. int targetListIndexLenght = targetList.Count;
  86. int forShout = startindex+ shouted;
  87.  
  88. if (targetListIndexLenght == shouted)
  89. {
  90. targetList[startindex] -= 5;
  91.  
  92. }
  93.  
  94. else if (forShout == targetListIndexLenght)
  95. { targetList[startindex] -= 5;
  96. }
  97. else if (forShout > targetListIndexLenght)
  98. {
  99. int left = forShout % targetListIndexLenght;
  100. if (left != 0)
  101. { targetList[left-1] -= 5; }
  102. else
  103. { targetList[startindex] -= 5; }
  104. }
  105. else if(forShout<targetListIndexLenght)
  106. { targetList[forShout-1] -= 5; }
  107.  
  108.  
  109. return targetList;
  110.  
  111. }
  112.  
  113.  
  114.  
  115. }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement