Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _03.CODEPhoenixOscarRomeoNovember
- {
- public class StartUp
- {
- public static void Main()
- {
- Dictionary<string, List<string>> squads = new Dictionary<string, List<string>>();
- List<string> check = new List<string>();
- while (true)
- {
- string input = Console.ReadLine();
- if (input == "Blaze it!")
- {
- break;
- }
- string creature = input.Substring(0, input.IndexOf('-') - 1).Trim();
- string squadMate = input.Substring(input.IndexOf('>') + 2).Trim();
- if (!squads.ContainsKey(creature))
- {
- squads.Add(creature, new List<string>());
- squads[creature].Add(squadMate);
- }
- else
- {
- if (squads[creature].Contains(squadMate) || creature == squadMate)
- {
- continue;
- }
- else
- {
- squads[creature].Add(squadMate);
- }
- }
- check.Add(squadMate + "" + creature);
- if (check.Contains(creature + "" + squadMate))
- {
- squads[creature].Remove(squadMate);
- squads[squadMate].Remove(creature);
- }
- }
- foreach (var squad in squads.OrderByDescending(x =>x.Value.Count))
- {
- Console.WriteLine($"{squad.Key} : {squad.Value.Count()}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment