Advertisement
Stan08

izpit/04.ForceBook

Jul 13th, 2018
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.Linq;
  4. using System.Globalization;
  5. using System.Collections.Generic;
  6. using System.Text;
  7.  
  8. public class Example
  9.  
  10. {
  11. public static void Main(string[] args)
  12.  
  13. {
  14. string input = Console.ReadLine();
  15. var users = new Dictionary<string, string>();
  16.  
  17. while (input != "Lumpawaroo")
  18. {
  19. if (input.Contains('|'))
  20. {
  21. string[] splt = input.Split('|').Select(s=>s.Trim()).ToArray();
  22.  
  23. if (!users.ContainsKey(splt[1]))
  24. {
  25. users.Add(splt[1], splt[0]);
  26. }
  27. }
  28. else
  29. {
  30. string[] splt = input.Split("->".ToCharArray()).Select(s=>s.Trim()).ToArray();
  31. if (users.ContainsKey(splt[0]))
  32. {
  33. users[splt[0]] = splt[2];
  34. Console.WriteLine($"{splt[0]} joins the {splt[2]} side!");
  35. }
  36. else
  37. {
  38. users.Add(splt[0], splt[2]);
  39. Console.WriteLine($"{splt[0]} joins the {splt[2]} side!");
  40.  
  41. }
  42. }
  43. input = Console.ReadLine();
  44. }
  45.  
  46. foreach (var side in users.GroupBy(x => x.Value).OrderByDescending(t => t.Count()).ThenBy(a=>a.Key))
  47. {
  48. Console.WriteLine($"Side: { side.Key}, Members: {side.Count()} ");
  49.  
  50. foreach(var user in side.OrderBy(d=>d.Key))
  51. {
  52. Console.WriteLine($"! {user.Key}");
  53. }
  54. }
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement