Advertisement
Spiderbait90

Untitled

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