Advertisement
Spiderbait90

Untitled

May 3rd, 2017
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.82 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Numerics;
  5. using System.Text;
  6. using System.Text.RegularExpressions;
  7. using System.Threading.Tasks;
  8.  
  9. namespace Practice
  10. {    
  11.     public class Program
  12.     {
  13.         public static void Main(string[] args)
  14.         {
  15.             var input = Console.ReadLine();
  16.             var data = new Dictionary<string, Dictionary<string, int>>();
  17.             var names = new List<string>();
  18.             while (input != "quit")
  19.             {
  20.                 var split = input.Split(new[] { '-', '>' }
  21.                 , StringSplitOptions.RemoveEmptyEntries);
  22.  
  23.                 var name = split[0].Trim();
  24.                 var team = split[1].Trim();
  25.                 var score = int.Parse(split[2].Trim());
  26.  
  27.                 if (names.Contains(name))
  28.                 {
  29.                    
  30.                 }
  31.                 else
  32.                 {
  33.                     names.Add(name);
  34.                     if (!data.ContainsKey(team))
  35.                         data[team] = new Dictionary<string, int>();
  36.  
  37.                     data[team].Add(name, score);
  38.                 }
  39.  
  40.                 input = Console.ReadLine();
  41.             }
  42.             var count = 1;
  43.  
  44.             var newdata = data
  45.                 .OrderByDescending(x => x.Value.Values.Sum())
  46.                 .ThenByDescending(x => x.Value.Values.Average());
  47.  
  48.             foreach (var team in newdata)
  49.             {
  50.                 var sum = team.Value.Values.Sum();
  51.  
  52.                 Console.WriteLine($"{count}. Team: {team.Key} - {sum}");
  53.                 foreach (var worm in team.Value.OrderByDescending(x => x.Value))
  54.                 {
  55.                     Console.WriteLine($"###{worm.Key} : {worm.Value}");
  56.                 }
  57.                 count++;
  58.             }
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement