Guest User

Roli The Coder

a guest
Nov 2nd, 2016
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.74 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Security.Cryptography.X509Certificates;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. //ReSharper disable All
  8.  
  9. namespace _02
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             string input = Console.ReadLine();
  16.             Dictionary<int, Dictionary<string, List<string>>> eventDictionary = new Dictionary<int, Dictionary<string, List<string>>>();
  17.             while (!(input.Equals("Time for Code")))
  18.             {
  19.                 string[] data = input.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
  20.                 if (data[1].Contains('#'))
  21.                 {
  22.                     int id = int.Parse(data[0]);
  23.                     string eventName = data[1].Substring(1);
  24.                     List<string> participants = new List<string>();
  25.                     for (int i = 2; i < data.Length; i++)
  26.                     {
  27.                         participants.Add(data[i]);
  28.                     }
  29.                     participants.Distinct();
  30.  
  31.                     if (!(eventDictionary.ContainsKey(id)))
  32.                     {
  33.                         Dictionary<string,List<string>> inputData = new Dictionary<string, List<string>>();
  34.                         inputData.Add(eventName,participants);
  35.                         eventDictionary.Add(id,inputData);
  36.                     }else if (eventDictionary.ContainsKey(id)&& eventDictionary[id].ContainsKey(eventName))
  37.                     {
  38.                         Dictionary<string, List<string>> inputData = new Dictionary<string, List<string>>();
  39.                         inputData = eventDictionary[id];
  40.                         foreach (string part in participants)
  41.                         {
  42.                             inputData[eventName].Add(part);
  43.                         }
  44.                         inputData[eventName].Distinct();
  45.                         eventDictionary[id] = inputData;
  46.                     }
  47.  
  48.                 }
  49.                 input = Console.ReadLine();
  50.             }
  51.             //eventDictionary =
  52.             //    eventDictionary.OrderByDescending(x => x.Value.Count())
  53.             //        .ThenBy(x => x.Value.Keys)
  54.             //        .ToDictionary(x => x.Key, x => x.Value);
  55.             foreach (var id in eventDictionary)
  56.             {
  57.                 foreach (var eventT in id.Value)
  58.                 {
  59.                     Console.WriteLine($"{eventT.Key} - {eventT.Value.Count()}");
  60.                     foreach (var participants in eventT.Value.OrderBy(x=>x))
  61.                     {
  62.                         Console.WriteLine(participants);
  63.                     }
  64.                 }
  65.             }
  66.         }
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment