Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace PokemonEvolution
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, Dictionary<string, List<int>>> pokemonsData = new Dictionary<string, Dictionary<string, List<int>>>();
- string input;
- while ((input = Console.ReadLine()) != "wubbalubbadubdub")
- {
- string[] tokens = input
- .Split(new char[] { '-', '>', ' ' }, StringSplitOptions.RemoveEmptyEntries);
- string pokemonName = tokens[0];
- if (tokens.Length == 1)
- {
- if (pokemonsData.ContainsKey(pokemonName))
- {
- Console.WriteLine("# {0}", pokemonName);
- foreach (var evolution in pokemonsData[pokemonName])
- {
- string pokeEvolution = evolution.Key;
- foreach (var index in evolution.Value.OrderByDescending(x => x))
- {
- Console.WriteLine("{0} <-> {1}", pokeEvolution, index);
- }
- }
- }
- continue;
- }
- string evolutionType = tokens[1];
- int evolutionIndex = int.Parse(tokens[2]);
- if (!pokemonsData.ContainsKey(pokemonName))
- {
- pokemonsData.Add(pokemonName, new Dictionary<string, List<int>>());
- }
- if (!pokemonsData[pokemonName].ContainsKey(evolutionType))
- {
- pokemonsData[pokemonName].Add(evolutionType, new List<int>());
- }
- pokemonsData[pokemonName][evolutionType].Add(evolutionIndex);
- }
- foreach (var name in pokemonsData)
- {
- string pokeName = name.Key;
- Console.WriteLine("# {0}", pokeName);
- foreach (var evolution in name.Value)
- {
- string pokeEvolution = evolution.Key;
- foreach (var index in evolution.Value.OrderByDescending(x => x))
- {
- Console.WriteLine("{0} <-> {1}", pokeEvolution, index);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement