Advertisement
Guest User

Untitled

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