Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Security.Cryptography.X509Certificates;
- using System.Text;
- using System.Threading.Tasks;
- //ReSharper disable All
- namespace _02
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- Dictionary<int, Dictionary<string, List<string>>> eventDictionary = new Dictionary<int, Dictionary<string, List<string>>>();
- while (!(input.Equals("Time for Code")))
- {
- string[] data = input.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
- if (data[1].Contains('#'))
- {
- int id = int.Parse(data[0]);
- string eventName = data[1].Substring(1);
- List<string> participants = new List<string>();
- for (int i = 2; i < data.Length; i++)
- {
- participants.Add(data[i]);
- }
- participants.Distinct();
- if (!(eventDictionary.ContainsKey(id)))
- {
- Dictionary<string,List<string>> inputData = new Dictionary<string, List<string>>();
- inputData.Add(eventName,participants);
- eventDictionary.Add(id,inputData);
- }else if (eventDictionary.ContainsKey(id)&& eventDictionary[id].ContainsKey(eventName))
- {
- Dictionary<string, List<string>> inputData = new Dictionary<string, List<string>>();
- inputData = eventDictionary[id];
- foreach (string part in participants)
- {
- inputData[eventName].Add(part);
- }
- inputData[eventName].Distinct();
- eventDictionary[id] = inputData;
- }
- }
- input = Console.ReadLine();
- }
- //eventDictionary =
- // eventDictionary.OrderByDescending(x => x.Value.Count())
- // .ThenBy(x => x.Value.Keys)
- // .ToDictionary(x => x.Key, x => x.Value);
- foreach (var id in eventDictionary)
- {
- foreach (var eventT in id.Value)
- {
- Console.WriteLine($"{eventT.Key} - {eventT.Value.Count()}");
- foreach (var participants in eventT.Value.OrderBy(x=>x))
- {
- Console.WriteLine(participants);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment