Advertisement
Guest User

Roli - The Coder

a guest
Oct 24th, 2016
788
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace Roli_The_Coder
  6. {
  7. public class Program
  8. {
  9. public static void Main()
  10. {
  11. string inputLine = Console.ReadLine();
  12. Dictionary<int, Event> eventsBook = new Dictionary<int, Event>();
  13.  
  14. while (!inputLine.Equals("Time for Code"))
  15. {
  16. string[] inputElements = inputLine
  17. .Split(new char[] { ' ', '\t','\r','\n' }, StringSplitOptions.RemoveEmptyEntries);
  18.  
  19. if (!inputElements[1].Contains('#'))
  20. {
  21. inputLine = Console.ReadLine();
  22. continue;
  23. }
  24.  
  25. int eventId = int.Parse(inputElements[0]);
  26. char[] eventName = inputElements[1].Skip(1).ToArray();
  27. string name = string.Join("", eventName);
  28.  
  29. if (eventsBook.ContainsKey(eventId) && !eventsBook[eventId].Name.Equals(name))
  30. {
  31. inputLine = Console.ReadLine();
  32. continue;
  33. }
  34.  
  35. else if (eventsBook.ContainsKey(eventId) && eventsBook[eventId].Name.Equals(name))
  36. {
  37. for (int i = 2; i < inputElements.Length; i++)
  38. {
  39. if (eventsBook[eventId].partisipant.Contains(inputElements[i]))
  40. {
  41. continue;
  42. }
  43. else
  44. {
  45. eventsBook[eventId].partisipant.Add(inputElements[i]);
  46. }
  47. }
  48. }
  49.  
  50. else
  51. {
  52. Event currentEvent = new Event();
  53. currentEvent.Name = name;
  54.  
  55. for (int i = 2; i < inputElements.Length; i++)
  56. {
  57. if (!inputElements[i].Contains('@'))
  58. {
  59. continue;
  60. }
  61.  
  62. currentEvent.partisipant.Add(inputElements[i]);
  63. }
  64. eventsBook[eventId] = currentEvent;
  65. }
  66.  
  67. inputLine = Console.ReadLine();
  68. }
  69. eventsBook=eventsBook
  70. .OrderByDescending(v => v.Value.partisipant.Count())
  71. .ThenBy(v=>v.Value.Name)
  72. .ToDictionary(x=>x.Key,x=>x.Value);
  73.  
  74. foreach (var evenT in eventsBook)
  75. {
  76. Console.WriteLine($"{evenT.Value.Name} - { evenT.Value.partisipant.Count()}");
  77. foreach (var item in evenT.Value.partisipant.OrderBy(x => x))
  78. {
  79. Console.WriteLine(item);
  80. }
  81. }
  82. }
  83. }
  84.  
  85. public class Event
  86. {
  87.  
  88. public Event()
  89. {
  90. this.partisipant = new List<string>();
  91. }
  92. public List<string> partisipant { get; set; }
  93. public string Name { get; set; }
  94. }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement