SHARE
TWEET

4. Snowwhite

anizko Jul 19th, 2019 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _04._Snowwhite
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.  
  12.             Dictionary<string, Dictionary<string, int>> dict = new Dictionary<string, Dictionary<string, int>>();
  13.             string comand = Console.ReadLine();
  14.  
  15.             while(comand!= "Once upon a time")
  16.             {
  17.                 string[] infoDwarfs = comand.Split(new String[] { " <:> " }, StringSplitOptions.None);
  18.                 string dwarfName = infoDwarfs[0];
  19.                 string dwarfHatColor = infoDwarfs[1];
  20.                 int dwarfPhysics = int.Parse(infoDwarfs[2]);
  21.  
  22.                 if(! dict.ContainsKey(dwarfName))
  23.                 {
  24.                     dict[dwarfName] = new Dictionary<string, int>();
  25.                 }
  26.                 if(! dict[dwarfName].ContainsKey(dwarfHatColor))
  27.                 {
  28.                     dict[dwarfName][dwarfHatColor] = 0;
  29.                 }
  30.                 if(dict[dwarfName][dwarfHatColor]< dwarfPhysics)
  31.                 {
  32.                     dict[dwarfName][dwarfHatColor] = dwarfPhysics;
  33.                 }
  34.  
  35.                 comand = Console.ReadLine();
  36.             }
  37.  
  38.             foreach (var item in dict.OrderByDescending(x => x.Value.Values)
  39.                 .ThenByDescending(x => dict.Where(y=>y.Value.Keys==x.Value.Keys).Count()))
  40.  
  41.             {
  42.                 Console.WriteLine($"({item.Value.Keys}) {item.Key} <-> {item.Value.Values}");
  43.             }
  44.            
  45.         }
  46.     }
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top