Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _04._ForceBook
- {
- class Program
- {
- static void Main(string[] args)
- {
- string line = Console.ReadLine();
- Dictionary<string, List<string>> listOfSides = new Dictionary<string, List<string>>();
- while (line != "Lumpawaroo")
- {
- List<string> users = new List<string>();
- if (line.Contains("|"))
- {
- string[] input = line.Split(new [] { " | " }, StringSplitOptions.RemoveEmptyEntries);
- string side = input[0];
- string user = input[1];
- if (!listOfSides.ContainsKey(side))
- {
- if (!users.Contains(user))
- {
- users.Add(user);
- listOfSides.Add(side, users);
- }
- }
- //Is it necessary to make some other cheques
- }
- else
- {
- string[] input = line.Split(new [] { " -> " }, StringSplitOptions.RemoveEmptyEntries);
- string side = input[1];
- string user = input[0];
- if (side == "Lighter" && listOfSides["Darker"].Contains(user))
- {
- listOfSides["Darker"].Remove(user);
- }
- else if (side == "Darker" && listOfSides["Lighter"].Contains(user))
- {
- listOfSides["Lighter"].Remove(user);
- }
- if (!listOfSides.ContainsKey(side))
- {
- if (!users.Contains(user))
- {
- users.Add(user);
- listOfSides.Add(side, users);
- Console.WriteLine($"{user} joins the {side} side!");
- }
- //Is it necessary to make some other cheques
- }
- else
- {
- listOfSides[side].Add(user);
- Console.WriteLine($"{user} joins the {side} side!");
- }
- }
- line = Console.ReadLine();
- }
- foreach (var pear in listOfSides.OrderBy(x=>x.Key))
- {
- if (pear.Value.Count > 0)
- {
- Console.WriteLine($"Side: {pear.Key}, Members: {pear.Value.Count}");
- }
- foreach (var item in pear.Value.OrderBy(x=>x))
- {
- Console.WriteLine($"! {string.Join(',', item)}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement