Advertisement
HristoGrigorov

RabbitHole

Mar 1st, 2017
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _301.RabbitHole
  8. {
  9. class RabbitHole
  10. {
  11. static void Main(string[] args)
  12. {
  13. List<string> command = Console.ReadLine().Split(' ').ToList();
  14. int energy = int.Parse(Console.ReadLine());
  15.  
  16. int currentIndex = 0;
  17. bool isDeadFromBomb = false;
  18.  
  19. while (energy > 0)
  20. {
  21. isDeadFromBomb = false;
  22. string[] currentCommand = command[currentIndex].Split('|');
  23. string action = currentCommand[0];
  24.  
  25. if (action == "RabbitHole")
  26. {
  27. Console.WriteLine("You have 5 years to save Kennedy!");
  28. break;
  29. }
  30.  
  31. int value = int.Parse(currentCommand[1]);
  32.  
  33. switch (action)
  34. {
  35.  
  36. case "Left":
  37. currentIndex = Math.Abs(currentIndex - value) % command.Count;
  38. energy -= value;
  39. break;
  40.  
  41. case "Right":
  42. currentIndex = (currentIndex + value) % command.Count;
  43. energy -= value;
  44. break;
  45.  
  46. case "Bomb":
  47. command.RemoveAt(currentIndex);
  48. currentIndex = 0;
  49. energy -= value;
  50. isDeadFromBomb = true;
  51. break;
  52. }
  53.  
  54. if (command[command.Count - 1] != "RabbitHole")
  55. {
  56. command.RemoveAt(command.Count - 1);
  57. }
  58. command.Add("Bomb|" + energy);
  59.  
  60.  
  61. if (energy <= 0 && isDeadFromBomb)
  62. {
  63. Console.WriteLine("You are dead due to bomb explosion!");
  64. }
  65. else if (energy <= 0 && !isDeadFromBomb)
  66. {
  67. Console.WriteLine("You are tired. You can't continue the mission.");
  68. }
  69. }
  70. }
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement