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._Snowwhite
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, Dictionary<string, int>> dict = new Dictionary<string, Dictionary<string, int>>();
- string comand = Console.ReadLine();
- while(comand!= "Once upon a time")
- {
- string[] infoDwarfs = comand.Split(new String[] { " <:> " }, StringSplitOptions.None);
- string dwarfName = infoDwarfs[0];
- string dwarfHatColor = infoDwarfs[1];
- int dwarfPhysics = int.Parse(infoDwarfs[2]);
- if(! dict.ContainsKey(dwarfName))
- {
- dict[dwarfName] = new Dictionary<string, int>();
- }
- if(! dict[dwarfName].ContainsKey(dwarfHatColor))
- {
- dict[dwarfName][dwarfHatColor] = 0;
- }
- if(dict[dwarfName][dwarfHatColor]< dwarfPhysics)
- {
- dict[dwarfName][dwarfHatColor] = dwarfPhysics;
- }
- comand = Console.ReadLine();
- }
- foreach (var item in dict.OrderByDescending(x => x.Value.Values)
- .ThenByDescending(x => dict.Where(y=>y.Value.Keys==x.Value.Keys).Count()))
- {
- Console.WriteLine($"({item.Value.Keys}) {item.Key} <-> {item.Value.Values}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement