Advertisement
tochka

Pokemon Evolution

Feb 19th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.24 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Numerics;
  7.  
  8. namespace ConsoleApp115
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             Dictionary<string, Dictionary<List<string>, long>> data = new Dictionary<string, Dictionary<List<string>, long>>();
  15.  
  16.             string[] info = Console.ReadLine()
  17.                 .Split(new string[] { " -> " }, StringSplitOptions.RemoveEmptyEntries);
  18.  
  19.  
  20.             while (info[0] != "wubbalubbadubdub")
  21.             {
  22.                 string name = info[0];
  23.  
  24.                 if (info.Length == 1)
  25.                 {
  26.                     if (data.ContainsKey(name))
  27.                     {
  28.                         Console.WriteLine($"# {name}");
  29.                         foreach (var item in data[name])
  30.                         {
  31.                             Console.WriteLine($"{string.Join(" ", item.Key)} <-> {item.Value}");
  32.                         }
  33.                     }
  34.                 }
  35.                 else
  36.                 {
  37.                     List<string> type = new List<string>();
  38.                     type.Add(info[1]);
  39.                     long index = long.Parse(info[2]);
  40.  
  41.                     if (!data.ContainsKey(name))
  42.                     {
  43.                         data.Add(name, new Dictionary<List<string>, long>());
  44.                     }
  45.  
  46.                     if (!data[name].ContainsKey(type))
  47.                     {
  48.                         data[name].Add(type, index);
  49.                     }
  50.  
  51.                     if (!data[name].ContainsValue(index))
  52.                     {
  53.                         data[name][type] = index;
  54.                     }
  55.  
  56.  
  57.                 }
  58.  
  59.                 info = Console.ReadLine()
  60.                 .Split(new string[] { " -> " }, StringSplitOptions.RemoveEmptyEntries);
  61.             }
  62.  
  63.             foreach (var item in data)
  64.             {
  65.                 Console.WriteLine($"# {item.Key}");
  66.  
  67.                 foreach (var itemm in item.Value.OrderByDescending(a => a.Value))
  68.                 {
  69.                     Console.WriteLine($"{string.Join(" ", itemm.Key)} <-> {itemm.Value}");
  70.                 }
  71.             }
  72.  
  73.         }
  74.     }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement