Advertisement
paykova

RoliTheCoder

Mar 9th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 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.RoliTheCoder
  8. {
  9. public class RoliTheCoder
  10. {
  11. public static void Main()
  12. {
  13. string input = Console.ReadLine();
  14.  
  15. Dictionary<string, Dictionary<string, List<string>>> dict =
  16. new Dictionary<string, Dictionary<string, List<string>>>();
  17. List<string> list = new List<string>();
  18.  
  19. while (input != "Time for Code")
  20. {
  21. string[] inputLine = input
  22. .Split(" @".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
  23. .Select(a => a.Trim())
  24. .ToArray();
  25.  
  26. string ID = inputLine[0];
  27. string name = inputLine[1];
  28.  
  29. if (name.Contains('#'))
  30. {
  31. if (!dict.ContainsKey(ID))
  32. {
  33. dict.Add(ID, new Dictionary<string, List<string>>());
  34.  
  35. if (!dict[ID].ContainsKey(name))
  36. {
  37. dict[ID].Add(name, new List<string>());
  38. for (int i = 2; i < inputLine.Length; i++)
  39. {
  40. dict[ID][name].Add(inputLine[i]);
  41. }
  42. }
  43. else
  44. {
  45.  
  46. for (int i = 2; i < inputLine.Length; i++)
  47. {
  48. if (!dict[ID][name].Contains(inputLine[i]))
  49. {
  50. dict[ID][name].Add(inputLine[i]);
  51. }
  52. }
  53. }
  54. }
  55. if (dict.ContainsKey(ID))
  56. {
  57. if (dict[ID].ContainsKey(name))
  58. {
  59. for (int i = 2; i < inputLine.Length; i++)
  60. {
  61. if (!dict[ID][name].Contains(inputLine[i]))
  62. {
  63. dict[ID][name].Add(inputLine[i]);
  64. }
  65. }
  66. }
  67. }
  68. }
  69. input = Console.ReadLine();
  70. }
  71. foreach (KeyValuePair<string, Dictionary<string, List<string>>> kvp in dict
  72. .OrderByDescending(kvp => kvp.Value.Values.Count()))
  73. {
  74. foreach (var item in kvp.Value.OrderByDescending(x => x.Value.Count()).ThenBy(x => x.Key))
  75. {
  76. Console.Write(item.Key.Trim('#'));
  77. Console.WriteLine($" - {item.Value.Count()}");
  78. foreach (var it in item.Value.OrderBy(x => x))
  79. {
  80. Console.WriteLine("@" + it);
  81. }
  82. }
  83. }
  84. }
  85. }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement