Stan08

Problem 2 – Snowmen

Aug 24th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. namespace _2.Snowman_2
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. List<int> input = Console.ReadLine().Split().Select(int.Parse).ToList();
  11. List<int> loss = new List<int>();
  12.  
  13.  
  14. while (input.Count != 1)
  15. {
  16.  
  17.  
  18. for (int i = 0; i < input.Count; i++)
  19. {
  20. if (Math.Abs(loss.Count - input.Count) == 1)
  21. {
  22. continue;
  23. }
  24. if (loss.Any(x => x == i))
  25. {
  26. continue;
  27. }
  28.  
  29. int tar = input[i];
  30. int at = i;
  31. if (tar >= input.Count)
  32. {
  33. tar = tar % input.Count;
  34. }
  35.  
  36. int diff = Math.Abs(at - tar);
  37.  
  38. if (diff == 0)
  39. {
  40. Console.WriteLine($"{at} performed harakiri");
  41. loss.Add(at);loss = loss.Distinct().ToList();
  42. }
  43. else if (diff != 0 && diff % 2 == 0)
  44. {
  45. Console.WriteLine($"{at} x {tar} -> {at} wins");
  46.  
  47. loss.Add(tar);
  48. loss = loss.Distinct().ToList();
  49.  
  50. }
  51. else
  52. {
  53. Console.WriteLine($"{at} x {tar} -> {tar} wins");
  54.  
  55. loss.Add(at);
  56. loss = loss.Distinct().ToList();
  57.  
  58. }
  59.  
  60. }
  61.  
  62. foreach (var c in loss.OrderByDescending(x => x).Distinct())
  63. {
  64.  
  65. input.RemoveAt(c);
  66.  
  67. }
  68. loss.Clear();
  69. }
  70.  
  71.  
  72. }
  73.  
  74.  
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment