Advertisement
Prohause

Pokemon Evolution

Feb 26th, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _09072017Pr4
  6. {
  7. internal class Program
  8. {
  9. private static void Main(string[] args)
  10. {
  11. var allPokemons = new Dictionary<string, List<KeyValuePair<string, int>>>();
  12.  
  13. var input = string.Empty;
  14.  
  15. while (!(input = Console.ReadLine()).Equals("wubbalubbadubdub"))
  16. {
  17. var tokens = input.Split(new[] { ' ', '-', '>' }, StringSplitOptions.RemoveEmptyEntries);
  18. if (tokens.Length == 1)
  19. {
  20. var pokemonName = tokens[0];
  21.  
  22. if (!allPokemons.ContainsKey(pokemonName)) continue;
  23. Console.WriteLine($"# {pokemonName}");
  24. foreach (var pokemon in allPokemons[pokemonName])
  25. {
  26. Console.WriteLine($"{pokemon.Key} <-> {pokemon.Value}");
  27. }
  28. }
  29. else
  30. {
  31. var pokemonType = tokens[0];
  32. var pokemonEvo = tokens[1];
  33. var pokemonIndex = int.Parse(tokens[2]);
  34.  
  35. if (!allPokemons.ContainsKey(pokemonType))
  36. {
  37. allPokemons.Add(pokemonType, new List<KeyValuePair<string, int>>());
  38. }
  39.  
  40. allPokemons[pokemonType].Add(new KeyValuePair<string, int>(pokemonEvo, pokemonIndex));
  41. }
  42. }
  43.  
  44. foreach (var pokemonType in allPokemons)
  45. {
  46. Console.WriteLine($"# {pokemonType.Key}");
  47.  
  48. foreach (var pokemonStat in pokemonType.Value.OrderByDescending(p => p.Value))
  49. {
  50. Console.WriteLine($"{pokemonStat.Key} <-> {pokemonStat.Value}");
  51. }
  52. }
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement