Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _05.PokemonEvolution
- {
- public class StartUp
- {
- public static void Main()
- {
- var pokemons = new Dictionary<string, List<KeyValuePair<string, long>>>();
- while (true)
- {
- string input = Console.ReadLine();
- if (input == "wubbalubbadubdub")
- {
- break;
- }
- var commandArgs = input
- .Split(new char[] { ' ', '>', '-' }, StringSplitOptions.RemoveEmptyEntries)
- .ToArray();
- if (commandArgs.Length == 3)
- {
- string pokemonName = commandArgs[0];
- string evolutionType = commandArgs[1];
- long evolutionIndex = long.Parse(commandArgs[2]);
- if (!pokemons.ContainsKey(pokemonName))
- {
- pokemons.Add(pokemonName, new List<KeyValuePair<string, long>>());
- pokemons[pokemonName].Add(new KeyValuePair<string, long>(evolutionType, evolutionIndex));
- }
- else
- {
- pokemons[pokemonName].Add(new KeyValuePair<string, long>(evolutionType, evolutionIndex));
- }
- }
- else
- {
- string pokemonName = commandArgs[0];
- if (pokemons.ContainsKey(pokemonName))
- {
- Console.WriteLine($"# {pokemonName}");
- foreach (var pokemon in pokemons[pokemonName])
- {
- Console.WriteLine($"{pokemon.Key} <-> {pokemon.Value}");
- }
- }
- }
- }
- foreach (var pokemon in pokemons)
- {
- Console.WriteLine($"# {pokemon.Key}");
- foreach (var item in pokemon.Value.OrderByDescending(x=>x.Value))
- {
- Console.WriteLine($"{item.Key} <-> {item.Value}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment