Advertisement
j0nze

MOBA Challenger

May 9th, 2018
652
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.26 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Dictionary<string, Dictionary<string, int>> playersStats = new Dictionary<string, Dictionary<string, int>>();
  14.             string player = "";
  15.             string position = "";
  16.             int skill = 0;
  17.             while (true)
  18.             {
  19.                 List<string> input = Console.ReadLine().Split(new char[] { ' ', '-', '>' }, StringSplitOptions.RemoveEmptyEntries).ToList();
  20.                 if (input[0] == "Season")
  21.                     break;
  22.  
  23.                 if (!(input.Contains("vs")))
  24.                 {
  25.                     player = input[0];
  26.                     position = input[1];
  27.                     skill = int.Parse(input[2]);
  28.  
  29.                     if (playersStats.ContainsKey(player))
  30.                     {
  31.                         if (playersStats[player].ContainsKey(position))
  32.                         {
  33.                             if (playersStats[player][position] < skill)                          
  34.                                 playersStats[player][position] = skill;                          
  35.                         }
  36.                         else                      
  37.                             playersStats[player][position] = skill;                      
  38.                     }
  39.                     else
  40.                     {
  41.                         Dictionary<string, int> assistDic = new Dictionary<string, int>();
  42.                         assistDic.Add(position, skill);
  43.                         playersStats[player] = assistDic;
  44.                     }
  45.  
  46.                 }
  47.                 else
  48.                 {
  49.                     string playerOne = input[0];
  50.                     string playerTwo = input[2];
  51.                     if (playersStats.ContainsKey(playerOne) && playersStats.ContainsKey(playerTwo))
  52.                     {
  53.                         foreach (var role in playersStats[playerOne])
  54.                         {
  55.                             foreach (var pos in playersStats[playerTwo])
  56.                             {
  57.                                 if (role.Key == pos.Key)
  58.                                 {
  59.                                     if (playersStats[playerOne].Values.Sum() > playersStats[playerTwo].Values.Sum())
  60.                                         playersStats.Remove(playerTwo);
  61.                                     else if (playersStats[playerOne].Values.Sum() < playersStats[playerTwo].Values.Sum())
  62.                                         playersStats.Remove(playerOne);
  63.                                 }
  64.                             }
  65.                         }
  66.                     }
  67.                 }
  68.             }
  69.             foreach (var playa in playersStats.OrderByDescending(x => x.Value.Values.Sum()).ThenBy(x => x.Key))
  70.             {
  71.                 Console.WriteLine($"{playa.Key}: {playa.Value.Values.Sum()} skill");
  72.                 foreach (var pair in playa.Value.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
  73.                 {
  74.                     Console.WriteLine($"- {pair.Key} <::> {pair.Value}");
  75.                 }
  76.             }
  77.         }
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement