Advertisement
Guest User

Untitled

a guest
Mar 12th, 2020
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _09_Exe_ForceBook
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. Dictionary<string, List<string>> forceUsers = new Dictionary<string, List<string>>();
  12.  
  13. string command = Console.ReadLine();
  14.  
  15. while (command != "Lumpawaroo")
  16. {
  17.  
  18. if (command.Contains("|"))
  19. {
  20. string[] commandArr = command.Split(" | ");
  21.  
  22. string forceSide = commandArr[0];
  23. string forceUser = commandArr[1];
  24.  
  25. if (!forceUsers.ContainsKey(forceSide))
  26. {
  27. forceUsers.Add(forceSide, new List<string>());
  28. }
  29. if (!forceUsers[forceSide].Contains(forceUser))
  30. {
  31. forceUsers[forceSide].Add(forceUser);
  32. }
  33. }
  34.  
  35. else
  36. {
  37. string[] commandArr = command.Split(" -> ");
  38.  
  39. string forceUser = commandArr[0];
  40. string forceSide = commandArr[1];
  41.  
  42.  
  43. if (!forceUsers.ContainsKey(forceSide))
  44. {
  45. forceUsers.Add(forceSide, new List<string>());
  46. }
  47.  
  48. forceUsers[forceSide].Add(forceUser);
  49.  
  50. Console.WriteLine($"{forceUser} joins the {forceSide} side!");
  51.  
  52. foreach (var values in forceUsers)
  53. {
  54. if (values.Value.Contains(forceUser)&&values.Key!=forceSide)
  55. {
  56. values.Value.Remove(forceUser);
  57. break;
  58. }
  59. }
  60.  
  61. }
  62.  
  63. command = Console.ReadLine();
  64. }
  65.  
  66. foreach (var users in forceUsers.OrderByDescending(x => x.Value.Count).ThenBy(c => c.Key))
  67. {
  68. if (users.Value.Count > 0)
  69. {
  70. Console.WriteLine($"Side: {users.Key}, Members: {users.Value.Count}");
  71. }
  72.  
  73. foreach (var elm in users.Value.OrderBy(t => t))
  74. {
  75. Console.WriteLine($"! {elm}");
  76. }
  77. }
  78. }
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement