Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Collections.Specialized;
- using System.Dynamic;
- using System.Linq;
- using System.Text.RegularExpressions;
- namespace _04._Roli_The_Coder
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = String.Empty;
- Dictionary<int, string> ID = new Dictionary<int, string>();
- Dictionary<string, List<string>> participant =
- new Dictionary<string, List<string>>();
- while ((input = Console.ReadLine()) != "Time for Code")
- {
- string[] tokens = input
- .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(x => x.Trim()).ToArray();
- int id = int.Parse(tokens[0]);
- string eventName = tokens[1];
- if (!eventName.StartsWith("#"))
- {
- continue;
- }
- string pattern = @"^(@[a-zA-Z0-9'-]+)$";
- if (!ID.ContainsKey(id))
- {
- ID.Add(id, eventName);
- participant.Add(eventName, new List<string>());
- for (int i = 2; i < tokens.Length; i++)
- {
- Match match = Regex.Match(tokens[i], pattern);
- if (match.Success)
- {
- if (!participant[eventName].Contains(tokens[i]))
- {
- participant[eventName].Add(tokens[i]);
- }
- }
- }
- }
- else if (ID.ContainsKey(id))
- {
- if (ID[id] == eventName)
- {
- if (participant.ContainsKey(eventName))
- {
- for (int i = 2; i < tokens.Length; i++)
- {
- Match match = Regex.Match(tokens[i], pattern);
- if (match.Success)
- {
- if (!participant[eventName].Contains(tokens[i]))
- {
- participant[eventName].Add(tokens[i]);
- }
- }
- }
- }
- }
- }
- }
- foreach (var kvp in participant.OrderByDescending(x => x.Value.Count).ThenBy(x => x.Key))
- {
- string name = kvp.Key.Substring(1);
- Console.WriteLine("{0} - {1}", name, kvp.Value.Count);
- var tempPart = kvp.Value;
- foreach (var part in tempPart.OrderBy(x => x))
- {
- Console.WriteLine(part);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement