Advertisement
YavorGrancharov

Roli___The_Coder

Aug 17th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.31 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Roli___The_Coder
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             string input = Console.ReadLine();
  12.  
  13.             Dictionary<string, List<string>> data = new Dictionary<string, List<string>>();
  14.             Dictionary<int, string> ids = new Dictionary<int, string>();
  15.  
  16.             while(input != "Time for Code")
  17.             {
  18.                 string[] tokens = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  19.                 int id = int.Parse(tokens[0]);
  20.                 string eventName = tokens[1];
  21.                 List<string> participants = tokens.Skip(2).ToList();
  22.  
  23.                 if (eventName[0] != '#')
  24.                 {
  25.  
  26.                 }
  27.                 else
  28.                 {
  29.                     if (ids.ContainsKey(id))
  30.                     {
  31.                         if (ids[id] == eventName)
  32.                         {
  33.                             foreach (var name in participants)
  34.                             {
  35.                                 if (!data[eventName].Contains(name))
  36.                                 {
  37.                                     data[eventName].Add(name);
  38.                                 }
  39.                             }
  40.                         }
  41.                     }
  42.                     else if (!ids.ContainsKey(id))
  43.                     {
  44.                         ids[id] = eventName;
  45.                         data[eventName] = new List<string>();
  46.  
  47.                         foreach (var name in participants)
  48.                         {
  49.                             if (!data[eventName].Contains(name))
  50.                             {
  51.                                 data[eventName].Add(name);
  52.                             }
  53.                         }
  54.                     }
  55.                 }
  56.                 input = Console.ReadLine();
  57.             }
  58.  
  59.             foreach (var eventt in data.OrderByDescending(x => x.Value.Count).ThenBy(x => x.Key))
  60.             {
  61.                 Console.WriteLine($"{eventt.Key.Remove(0, 1)} - {eventt.Value.Count}");
  62.                 foreach (var name in eventt.Value.OrderBy(x => x))
  63.                 {
  64.                     Console.WriteLine($"{name}");
  65.                 }
  66.             }
  67.         }
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement