Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _01_RabbitHole
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> input = Console.ReadLine().Split(' ').ToList();
- int allPower = int.Parse(Console.ReadLine());
- string comand = string.Empty;
- int energy = 0;
- string startValue = string.Empty;
- do
- {
- startValue = input[0];
- if (startValue == "RabbitHole")
- {
- Console.WriteLine("You have 5 years to save Kennedy!");
- break;
- }
- else
- {
- //ExtractComandsAndEnergy(startValue, comand, energy);
- string[] comandsAndEnerges = new string[2];
- comandsAndEnerges = startValue.Split('|');
- comand = comandsAndEnerges[0].ToString();
- energy = int.Parse(comandsAndEnerges[1]);
- int currentIndex = 0;
- switch (comand)
- {
- case "Right":
- currentIndex = (energy + currentIndex) % input.Count;
- allPower -= energy;
- startValue = input[currentIndex];
- break;
- case "Left":
- currentIndex = (energy - currentIndex) % input.Count;
- allPower -= energy;
- startValue = input[currentIndex];
- break;
- case "Bomb":
- input.RemoveAt(currentIndex);
- allPower -= energy;
- if (allPower <= 0)
- {
- Console.WriteLine("You are dead due to bomb explosion!");
- }
- break;
- }
- if (input[input.Count - 1] == "RubbitHole")
- {
- string newElement = "Bomb|" + allPower.ToString();
- input.Add(newElement);
- }
- else
- {
- input.RemoveAt(input.Count - 1);
- string newElement = "Bomb|" + allPower.ToString();
- input.Add(newElement);
- }
- }
- } while (allPower > 0);
- if (allPower <= 0 && comand != "Bomb" && comand != "RabbitHole")
- {
- Console.WriteLine("You are tired. You can't continue the mission.");
- }
- }
- private static void ExtractComandsAndEnergy(string startValue, string comand, int energy)
- {
- string[] comandsAndEnerges = new string[2];
- comandsAndEnerges = startValue.Split('|');
- comand = comandsAndEnerges[0].ToString();
- energy = int.Parse(comandsAndEnerges[1]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment