Advertisement
Guest User

Untitled

a guest
May 25th, 2018
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Numerics;
  5.  
  6. namespace Snowwhite
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. string input = Console.ReadLine();
  13. List<Dwarf> dwarf = new List<Dwarf>();
  14.  
  15. while (input != "Once upon a time")
  16. {
  17. string[] splitedInput = input.Split(new string[] { " <:> " }, StringSplitOptions.None);
  18.  
  19. string dwarfName = splitedInput[0];
  20. string dwarfColor = splitedInput[1];
  21. BigInteger dwarfPhysics = BigInteger.Parse(splitedInput[2]);
  22.  
  23. Dwarf dd = new Dwarf();
  24.  
  25. dd.Color = dwarfColor;
  26. dd.Name = dwarfName;
  27. dd.Physics = dwarfPhysics;
  28.  
  29. bool contains = false;
  30.  
  31. for (int i = 0; i < dwarf.Count; i++)
  32. {
  33. if (dwarf[i].Name == dd.Name && dwarf[i].Color == dd.Color)
  34. {
  35. if (dwarf[i].Physics < dd.Physics) dwarf[i].Physics = dd.Physics;
  36. contains = true;
  37. }
  38. }
  39.  
  40. if (!contains)
  41. {
  42. dwarf.Add(dd);
  43. }
  44.  
  45. input = Console.ReadLine();
  46. }
  47.  
  48.  
  49. foreach (var item in dwarf.OrderByDescending(z => z.Physics).ThenByDescending(z => z.Color.Count()))
  50. {
  51. Console.WriteLine($"({item.Color}) {item.Name} <-> {item.Physics}");
  52. }
  53. }
  54.  
  55. class Dwarf
  56. {
  57. public string Color { get; set; }
  58. public string Name { get; set; }
  59. public BigInteger Physics { get; set; }
  60. }
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement