Advertisement
esend3

RoliTheCoder

Oct 26th, 2016
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.44 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Application
  8. {
  9.     class MainClass
  10.     {
  11.         public static void Main(string[] args)
  12.         {
  13.  
  14.             string input = Console.ReadLine();
  15.  
  16.             SortedDictionary<int, SortedDictionary<string, List<string>>> eventList =
  17.             new SortedDictionary<int, SortedDictionary<string, List<string>>>();
  18.            
  19.  
  20.             while (!input.Equals("Time for Code"))
  21.             {
  22.                 string[] inputArgs = input.Split(new char[] { ' ' },
  23.                                          StringSplitOptions.RemoveEmptyEntries).ToArray();
  24.  
  25.                 int id = int.Parse(inputArgs[0]);
  26.                 string eventWithHash = inputArgs[1];
  27.                 string eventName = inputArgs[1].Substring(1);
  28.                 List<string> participants = new List<string>(inputArgs.Skip(2));
  29.  
  30.                 if (eventWithHash[0] != '#')
  31.                 {
  32.                     goto inpt;
  33.                 }
  34.                 if (!eventList.ContainsKey(id))
  35.                 {
  36.                     eventList.Add(id, new SortedDictionary<string, List<string>>());
  37.                 }
  38.                 else if (!eventList[id].ContainsKey(eventName))
  39.                 {
  40.                     goto inpt;
  41.                 }
  42.                
  43.                 if (eventList[id].ContainsKey(eventName))
  44.                 {
  45.                     foreach (string participant in participants)
  46.                     {
  47.                         eventList[id][eventName].Add(participant);
  48.                     }
  49.                     goto inpt;
  50.                 }
  51.                 eventList[id][eventName] = participants;
  52.  
  53.             inpt:
  54.                 input = Console.ReadLine();
  55.  
  56.             }
  57.  
  58.             foreach (var res in eventList.OrderByDescending(x=> x.Value.Values.Sum(y=> y.Count)))
  59.             {
  60.                 List<string> helper = new List<string>();
  61.                 foreach (var meet in res.Value)
  62.                 {  
  63.                     helper = meet.Value.Distinct().ToList();
  64.                     helper.Sort();
  65.                     int count = helper.Count;
  66.                     Console.WriteLine("{0} - {1}", meet.Key, count);
  67.                 }
  68.                 foreach (var help in helper)
  69.                 {
  70.                     Console.WriteLine("{0}", help);
  71.                 }
  72.             }
  73.         }
  74.     }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement