static void Main(string[] args) { Dictionary <string, List <PokemonEvolution> > pokemons = new Dictionary <string, List <PokemonEvolution> >(); while (true) { var input = Console.ReadLine().Split(new string[] { " -> " }, StringSplitOptions.RemoveEmptyEntries) .ToArray(); string pokemonName = input[0]; if (input[0] == "wubbalubbadubdub") { break; } if (input.Length > 1) { pokemonName = input[0]; string pokemonType = input[1]; int pokemonIndex = int.Parse(input[2]); PokemonEvolution pokemon = new PokemonEvolution { EvolutionType = pokemonType, EvolutionIndex = pokemonIndex }; if (!pokemons.ContainsKey(pokemonName)) { pokemons.Add(pokemonName, new List <PokemonEvolution>()); } pokemons[pokemonName].Add(pokemon); } else { if (pokemons.ContainsKey(pokemonName)) { Console.WriteLine($"# {pokemonName}"); foreach (var item in pokemons[pokemonName]) { Console.WriteLine($"{item.EvolutionType} <-> {item.EvolutionIndex}"); } } } } foreach (var pokey in pokemons) { Console.WriteLine($"# {pokey.Key}"); foreach (var item in pokey.Value.OrderByDescending(a => a.EvolutionIndex)) { Console.WriteLine($"{item.EvolutionType} <-> {item.EvolutionIndex}"); } } }
static void Main(string[] args) { string input = ""; var dictOfPokemons = new Dictionary <string, List <PokemonEvolution> >(); while ((input = Console.ReadLine()) != "wubbalubbadubdub") { if (dictOfPokemons.ContainsKey(input)) { printPokemon(input, dictOfPokemons); continue; } string[] slitedInput = input.Split(new string[] { " ", "-", ">" }, StringSplitOptions.RemoveEmptyEntries); if (slitedInput.Length != 3) { continue; } PokemonEvolution pokemons = new PokemonEvolution(); pokemons.Evolution = slitedInput[1]; pokemons.Index = int.Parse(slitedInput[2]); if (!dictOfPokemons.ContainsKey(slitedInput[0])) { dictOfPokemons.Add(slitedInput[0], new List <PokemonEvolution>()); dictOfPokemons[slitedInput[0]].Add(pokemons); } else { dictOfPokemons[slitedInput[0]].Add(pokemons); } } foreach (var item in dictOfPokemons) { Console.WriteLine("# {0}", item.Key); foreach (var items in item.Value.OrderByDescending(x => x.Index)) { Console.WriteLine("{0} <-> {1}", items.Evolution, items.Index); } } }