miroslavbstoyanov

Untitled

Nov 4th, 2017
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 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. var dictRoliTheCoder = new Dictionary<string, Dictionary<string, List<string>>>();
  14.  
  15. string input = "";
  16. while ((input = Console.ReadLine()) != "Time for Code")
  17. {
  18. string[] splitInput = input.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
  19. if (splitInput[1][0] != '#')
  20. {
  21. continue;
  22. }
  23. else
  24. {
  25. splitInput[1] = splitInput[1].Substring(1, splitInput[1].Length -1);
  26. }
  27.  
  28.  
  29. if (!dictRoliTheCoder.ContainsKey(splitInput[0]))
  30. {
  31. dictRoliTheCoder.Add(splitInput[0], new Dictionary<string, List<string>>());
  32. dictRoliTheCoder[splitInput[0]].Add(splitInput[1], new List<string>());
  33. }
  34.  
  35. if (dictRoliTheCoder[splitInput[0]].ContainsKey(splitInput[1]))
  36. {
  37. for (int i = 2; i < splitInput.Length; i++)
  38. {
  39. string check = splitInput[i].Substring(0,1);
  40. if (check == "@")
  41. {
  42. dictRoliTheCoder[splitInput[0]][splitInput[1]].Add(splitInput[i]);
  43. dictRoliTheCoder[splitInput[0]][splitInput[1]]
  44. = dictRoliTheCoder[splitInput[0]][splitInput[1]].Distinct().ToList();
  45. }
  46. }
  47. }
  48. }
  49. var result = new Dictionary<string, List<string>>();
  50.  
  51. foreach (var item in dictRoliTheCoder)
  52. {
  53. foreach (var items in item.Value)
  54. {
  55. result.Add(items.Key + " - " + items.Value.Count, items.Value);
  56. }
  57. }
  58. foreach (var item in result.OrderByDescending(x => x.Value.Count).ThenBy(y => y.Key))
  59. {
  60. Console.WriteLine("{0}", item.Key);
  61. if (item.Value.Count > 0)
  62. {
  63. Console.WriteLine("{0} ", String.Join("\n", item.Value.OrderBy(x => x)));
  64. }
  65. }
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment