Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace The_Great_Samurai_Battle
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> samuraiMasters = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
- int sequenceLength = samuraiMasters.Count;
- List<int> deadIndexes = new List<int>();
- while (sequenceLength > 1)
- {
- for (int attackerIndex = 0; attackerIndex < sequenceLength; attackerIndex++)
- {
- if (deadIndexes.Contains(attackerIndex))
- {
- continue;
- }
- int targetIndex = samuraiMasters[attackerIndex] % sequenceLength;
- int difference = Math.Abs(attackerIndex - targetIndex);
- if (difference == 0)
- {
- deadIndexes.Add(attackerIndex);
- Console.WriteLine($"{attackerIndex} performed harakiri");
- }
- else if (difference % 2 == 0)
- {
- deadIndexes.Add(targetIndex);
- Console.WriteLine($"{attackerIndex} x {targetIndex} -> {attackerIndex} wins");
- }
- else if (difference % 2 != 0)
- {
- deadIndexes.Add(attackerIndex);
- Console.WriteLine($"{attackerIndex} x {targetIndex} -> {targetIndex} wins");
- }
- }
- for (int i = 0; i < sequenceLength; i++)
- {
- if (deadIndexes.Contains(i))
- {
- samuraiMasters.RemoveAt(deadIndexes.IndexOf(i));
- }
- }
- deadIndexes.Clear();
- sequenceLength = samuraiMasters.Count;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement