Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Snowmen_01_18
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> snowmen = Console.ReadLine().Split().Select(int.Parse).ToList();
- List<int> losers = new List<int>();
- while (snowmen.Count > 1)
- {
- for (int index = 0; index < snowmen.Count; index++)
- {
- if (snowmen.Count - losers.Count == 1)
- {
- break;
- }
- int attacker = index;
- int target = snowmen[index] % snowmen.Count;
- if (losers.Contains(attacker))
- {
- continue;
- }
- int difference = Math.Abs(attacker - target);
- if (difference == 0)
- {
- Console.WriteLine($"{attacker} performed harakiri");
- losers.Add(attacker);
- losers = losers.Distinct().ToList();
- }
- else if (difference % 2 == 0)
- {
- Console.WriteLine($"{attacker} x {target} -> {attacker} wins");
- losers.Add(target);
- losers = losers.Distinct().ToList();
- }
- else if (difference % 2 != 0)
- {
- Console.WriteLine($"{attacker} x {target} -> {target} wins");
- losers.Add(attacker);
- losers = losers.Distinct().ToList();
- }
- }
- losers.Sort();
- losers.Reverse();
- foreach (int index in losers)
- {
- snowmen.RemoveAt(index);
- }
- losers.Clear();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment