Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace ForceBook
- {
- class Program
- {
- static void Main(string[] args)
- {
- string command = string.Empty;
- var users = new Dictionary<string, List<string>>();
- while ((command = Console.ReadLine()) != "Lumpawaroo")
- {
- if (command.Contains('|'))
- {
- var tokens = command.Split(" | ");
- var side = tokens[0];
- var user = tokens[1];
- if (!users.ContainsKey(side))
- {
- users.Add(side, new List<string>());
- }
- if (users.ContainsKey(side) && !users[side].Contains(user))
- {
- users[side].Add(user);
- }
- }
- else
- {
- var tokens = command.Split(" -> ");
- var side = tokens[1];
- var user = tokens[0];
- foreach (var kvp in users)
- {
- if (kvp.Value.Contains(user))
- {
- kvp.Value.Remove(user);
- break;
- }
- }
- if (!users.ContainsKey(side))
- {
- users.Add(side, new List<string>());
- }
- users[side].Add(user);
- Console.WriteLine($"{user} joins the {side} side!");
- }
- }
- foreach (var kvp in users.Where(x => x.Value.Count > 0).OrderByDescending(x => x.Value.Count).ThenBy(x => x.Key))
- {
- Console.WriteLine($"Side: {kvp.Key}, Members: {kvp.Value.Count()}");
- foreach (var user in kvp.Value.OrderBy(x => x))
- {
- Console.WriteLine($"! {user}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement