Advertisement
Guest User

SnowWhite

a guest
Mar 18th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace M04._Snowwhite
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. var dwarfColorNamePhyssics = new Dictionary<string, Dictionary<string, uint>>();
  12.  
  13. string input = string.Empty;
  14.  
  15. while ((input = Console.ReadLine()) != "Once upon a time")
  16. {
  17. string[] inputAsArray = input.Split(" <:> ");
  18.  
  19. string name = inputAsArray[0];
  20. string color = inputAsArray[1];
  21. uint physics = uint.Parse(inputAsArray[2]);
  22.  
  23. if (!dwarfColorNamePhyssics.ContainsKey(color))
  24. {
  25. dwarfColorNamePhyssics.Add(color, new Dictionary<string, uint>());
  26. dwarfColorNamePhyssics[color][name] = physics;
  27. }
  28.  
  29. else if (dwarfColorNamePhyssics.ContainsKey(color) && !dwarfColorNamePhyssics[color].ContainsKey(name))
  30. {
  31. dwarfColorNamePhyssics[color][name] = physics;
  32. }
  33.  
  34. else if (dwarfColorNamePhyssics.ContainsKey(color) && dwarfColorNamePhyssics[color].ContainsKey(name))
  35. {
  36. dwarfColorNamePhyssics[color][name] = Math.Max(dwarfColorNamePhyssics[color][name], physics);
  37.  
  38.  
  39. }
  40. }
  41.  
  42. foreach (var kvp in dwarfColorNamePhyssics
  43. .OrderByDescending(x => x.Value.Values.First()).ThenByDescending(x => x.Value.Count()))
  44.  
  45.  
  46.  
  47. {
  48. foreach (var item in kvp.Value.OrderByDescending(x => x.Value))
  49. {
  50. Console.WriteLine($"({kvp.Key}) {item.Key} <-> {item.Value}");
  51. }
  52. }
  53.  
  54.  
  55. }
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement