Advertisement
vasilivanov93

Untitled

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