Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _04.RoliTheCoder
- {
- public class RoliTheCoder
- {
- public static void Main()
- {
- string input = Console.ReadLine();
- Dictionary<string, Dictionary<string, List<string>>> dict =
- new Dictionary<string, Dictionary<string, List<string>>>();
- List<string> list = new List<string>();
- while (input != "Time for Code")
- {
- string[] inputLine = input
- .Split(" @".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
- .Select(a => a.Trim())
- .ToArray();
- string ID = inputLine[0];
- string name = inputLine[1];
- if (name.Contains('#'))
- {
- if (!dict.ContainsKey(ID))
- {
- dict.Add(ID, new Dictionary<string, List<string>>());
- if (!dict[ID].ContainsKey(name))
- {
- dict[ID].Add(name, new List<string>());
- for (int i = 2; i < inputLine.Length; i++)
- {
- dict[ID][name].Add(inputLine[i]);
- }
- }
- else
- {
- for (int i = 2; i < inputLine.Length; i++)
- {
- if (!dict[ID][name].Contains(inputLine[i]))
- {
- dict[ID][name].Add(inputLine[i]);
- }
- }
- }
- }
- if (dict.ContainsKey(ID))
- {
- if (dict[ID].ContainsKey(name))
- {
- for (int i = 2; i < inputLine.Length; i++)
- {
- if (!dict[ID][name].Contains(inputLine[i]))
- {
- dict[ID][name].Add(inputLine[i]);
- }
- }
- }
- }
- }
- input = Console.ReadLine();
- }
- foreach (KeyValuePair<string, Dictionary<string, List<string>>> kvp in dict
- .OrderByDescending(kvp => kvp.Value.Values.Count()))
- {
- foreach (var item in kvp.Value.OrderByDescending(x => x.Value.Count()).ThenBy(x => x.Key))
- {
- Console.Write(item.Key.Trim('#'));
- Console.WriteLine($" - {item.Value.Count()}");
- foreach (var it in item.Value.OrderBy(x => x))
- {
- Console.WriteLine("@" + it);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement