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;
- bool[] deadIndexes = new bool[sequenceLength];
- for (int i = 0; i < sequenceLength; i++)
- {
- deadIndexes[i] = true;
- }
- int trueCount = trueCount = deadIndexes.Count(x => x);
- while (trueCount != 1)
- {
- for (int attackerIndex = 0; attackerIndex < sequenceLength; attackerIndex++)
- {
- if (deadIndexes[attackerIndex] == false)
- {
- continue;
- }
- int targetIndex = samuraiMasters[attackerIndex] % sequenceLength;
- int difference = Math.Abs(attackerIndex - targetIndex);
- if (difference == 0)
- {
- deadIndexes[attackerIndex] = false; ;
- Console.WriteLine($"{attackerIndex} performed harakiri");
- //samuraiMasters.RemoveAt(attackerIndex);
- }
- else if (difference % 2 != 0)
- {
- deadIndexes[attackerIndex] = false; ;
- Console.WriteLine($"{attackerIndex} x {targetIndex} -> {targetIndex} wins");
- // samuraiMasters.RemoveAt(attackerIndex);
- }
- else if (difference % 2 == 0)
- {
- deadIndexes[targetIndex] = false;
- Console.WriteLine($"{attackerIndex} x {targetIndex} -> {attackerIndex} wins");
- //samuraiMasters.RemoveAt(targetIndex);
- }
- trueCount = deadIndexes.Count(x => x);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement