Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 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.Text.RegularExpressions;
  7.  
  8.  
  9. namespace ConsoleApplication15
  10. {
  11. class Program
  12. {
  13. static void Main(string[] args)
  14. {
  15. var input = Console.ReadLine();
  16. var list = new Dictionary<string, Pokemon>();
  17.  
  18. while (input != "wubbalubbadubdub")
  19. {
  20. var tempInput = input.Split(new string[] { " -> " }, StringSplitOptions.RemoveEmptyEntries).ToArray();
  21. if (tempInput.Length != 1)
  22. {
  23. var evolName = tempInput[1];
  24. var evolIndex = int.Parse(tempInput[2]);
  25. if (!list.ContainsKey(tempInput[0]))
  26. {
  27. list[tempInput[0]] = new Pokemon();
  28. }
  29. list[tempInput[0]].name = tempInput[0];
  30. if (list[tempInput[0]].evolution == null)
  31. {
  32. list[tempInput[0]].evolution = new List<Evolutions>();
  33. list[tempInput[0]].evolution.Add(new Evolutions { nameOfEv = evolName, evolIndex = evolIndex });
  34. }
  35. else
  36. list[tempInput[0]].evolution.Add(new Evolutions { nameOfEv = evolName, evolIndex = evolIndex });
  37. }
  38. else
  39. {
  40. foreach (var item in list.Values)
  41. {
  42. if (item.name == tempInput[0])
  43. {
  44. Console.WriteLine("# "+item.name);
  45. foreach (var item2 in item.evolution)
  46. {
  47. Console.WriteLine($"{item2.nameOfEv} <-> {item2.evolIndex}");
  48. }
  49. }
  50. }
  51. }
  52. input = Console.ReadLine();
  53.  
  54. }
  55.  
  56. foreach (var item in list.Values)
  57. {
  58. Console.WriteLine("# "+item.name);
  59. foreach (var item2 in item.evolution.OrderByDescending(x => x.evolIndex))
  60. {
  61. Console.WriteLine($"{item2.nameOfEv} <-> {item2.evolIndex}");
  62. }
  63. }
  64. }
  65.  
  66. }
  67. class Pokemon
  68. {
  69. public string name { get; set; }
  70. public List<Evolutions> evolution { get; set; }
  71. }
  72. class Evolutions
  73. {
  74. public string nameOfEv { get; set; }
  75. public int evolIndex { get; set; }
  76. }
  77.  
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement