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)
- {
- SortedDictionary<string, string> data = new SortedDictionary<string, string>();
- string userName = "";
- string side = "";
- while (true)
- {
- string input = Console.ReadLine();
- if (input == "Lumpawaroo")
- {
- break;
- }
- if (input.Contains("|"))
- {
- string[] user = input.Split("|").Select(tag => tag.Trim()).
- Where(tag => !string.IsNullOrEmpty(tag)).ToArray();
- side = user[0];
- userName = user[1];
- if (!data.ContainsKey(userName))
- {
- data.Add(userName, null);
- }
- data[userName] = side;
- }
- else if (input.Contains("->"))
- {
- string[] user = input.Split("->").Select(tag => tag.Trim()).
- Where(tag => !string.IsNullOrEmpty(tag)).ToArray();
- userName = user[0];
- side = user[1];
- if (!data.ContainsKey(userName))
- {
- data.Add(userName, null);
- }
- data[userName] = side;
- Console.WriteLine($"{userName} joins the {side} side!");
- }
- }
- Dictionary<string, int> count = new Dictionary<string, int>();
- foreach (var item in data)
- {
- if (!count.ContainsKey(item.Value))
- {
- count.Add(item.Value, 0);
- }
- count[item.Value] += 1;
- }
- foreach (var item in count.OrderBy(e=>e.Key))
- {
- Console.WriteLine($"Side: {item.Key}, Members: {item.Value}");
- foreach (var item2 in data)
- {
- if (item2.Value == item.Key)
- {
- Console.WriteLine($"! {item2.Key}");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement