Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Japanese_Roulette
  6. {
  7. class Program
  8. {
  9. static void Main()
  10. {
  11. var bullets = Console.ReadLine()
  12. .Split(' ')
  13. .Select(int.Parse)
  14. .ToList();
  15. var actions = Console.ReadLine()
  16. .Split(' ')
  17. .ToList();
  18. var index = bullets.IndexOf(1);
  19. bool someoneDied = false;
  20. int indexOfDeadPlayer = 0;
  21. for (int i = 0; i < actions.Count; i++)
  22. {
  23. var commands = actions[i]
  24. .Split(',')
  25. .ToList();
  26. var movement = int.Parse(commands[0]);
  27. var direction = commands[1];
  28. switch (direction)
  29. {
  30. case "Right":
  31. index = (index + movement) % bullets.Count;
  32. break;
  33. case "Left":
  34. for (int j = 0; j < movement; j++)
  35. {
  36. index--;
  37. if (index < 0)
  38. {
  39. index = bullets.Count - 1;
  40. }
  41. }
  42. break;
  43. }
  44. if (index == 2)
  45. {
  46. indexOfDeadPlayer = i;
  47. someoneDied = true;
  48. break;
  49. }
  50. if (index==bullets.Count-1)
  51. {
  52. index = 0;
  53. }
  54. else
  55. {
  56. index++;
  57. }
  58. }
  59. if (someoneDied)
  60. {
  61. Console.WriteLine("Game over! Player {0} is dead.", indexOfDeadPlayer);
  62. }
  63. else
  64. {
  65. Console.WriteLine("Everybody got lucky!");
  66. }
  67. }
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement