Advertisement
Guest User

Untitled

a guest
Mar 6th, 2017
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Japanese_Roulette
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int[] cylinder = Console.ReadLine().Split().Select(int.Parse).ToArray();
  14. string[] players = Console.ReadLine().Split().ToArray();
  15. bool dead = false;
  16.  
  17. for (int cylinderPosition = 0, p=0; cylinderPosition < cylinder.Length; cylinderPosition++, p++)
  18. {
  19. string[] command = players[p].Split(',');
  20. int strength = int.Parse(command[0]);
  21. if (command[1].Equals("Right"))
  22. {
  23. int cylinderState = (cylinderPosition + strength) % cylinder.Length;
  24. if (cylinder[cylinderState] == 1)
  25. {
  26. Console.WriteLine("Game over! Player {0} is dead.",p);
  27. dead = true;
  28. break;
  29. }
  30. else
  31. {
  32. cylinderPosition = cylinderState;
  33. }
  34. }
  35. else if (command[1].Equals("Left"))
  36. {
  37. int cylinderState = cylinder.Length % Math.Abs(cylinderPosition + strength);
  38. if (cylinder[cylinderState] == 1)
  39. {
  40. Console.WriteLine("Game over! Player {0} is dead.", p);
  41. dead = true;
  42. break;
  43. }
  44. else
  45. {
  46. cylinderPosition = cylinderState;
  47. }
  48. }
  49. if (p == players.Length)
  50. {
  51. break;
  52. }
  53. }
  54. if (!dead)
  55. {
  56. Console.WriteLine("Everybody got lucky!");
  57. }
  58. }
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement