Advertisement
YavorGrancharov

Rabbit_Hole(copy)

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