Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _02.JapaneseRoulette
- {
- public class JapaneseRoulette
- {
- public static void Main()
- {
- var cylinder = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
- var strength = Console.ReadLine().Split(' ').ToList();
- int startIndex = 2;
- int position = 0;
- bool isDead = false;
- int player = 0;
- for (int i = 0; i < strength.Count; i++)
- {
- player = i;
- var strengthAndDirection = strength[i].Split(',').ToList();
- int playerStrength = int.Parse(strengthAndDirection[0]);
- string playerDirection = strengthAndDirection[1];
- if (i == 0)
- {
- if (playerDirection == "Right")
- {
- position = (startIndex + playerStrength) % cylinder.Count;
- if (cylinder[position] == 1)
- {
- isDead = true;
- break;
- }
- }
- else if (playerDirection == "Left")
- {
- position = Math.Abs(startIndex - playerStrength) % cylinder.Count;
- if (cylinder[position] == 1)
- {
- isDead = true;
- break;
- }
- }
- }
- else
- {
- if (playerDirection == "Right")
- {
- position = (position + playerStrength) % cylinder.Count;
- if (cylinder[position] == 1)
- {
- isDead = true;
- break;
- }
- }
- else if (playerDirection == "Left")
- {
- position = Math.Abs(position - playerStrength) % cylinder.Count;
- if (cylinder[position] == 1)
- {
- isDead = true;
- break;
- }
- }
- }
- position++;
- if (position > cylinder.Count)
- {
- position = (position - 1) % cylinder.Count;
- }
- }
- if (false)
- {
- Console.WriteLine("Everybody got lucky!");
- }
- else
- {
- Console.WriteLine($"Game over! Player {player} is dead.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement