Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _04.PokemonEvolution
- {
- class PokemonEvolution
- {
- static void Main(string[] args)
- {
- var dictionary = new Dictionary<string, Dictionary<string, List<long>>>();
- var input = Console.ReadLine();
- while (input != "wubbalubbadubdub")
- {
- var inputArgs = input.Split(new[] { " -> " }, StringSplitOptions.RemoveEmptyEntries);
- var pokemon = inputArgs[0];
- if (inputArgs.Length>1)
- {
- var evolutionType = inputArgs[1];
- var evolutionIndex = long.Parse(inputArgs[2]);
- if (!dictionary.ContainsKey(pokemon))
- {
- dictionary.Add(pokemon, new Dictionary<string, List<long>>());
- }
- if (!dictionary[pokemon].ContainsKey(evolutionType))
- {
- dictionary[pokemon].Add(evolutionType, new List<long>());
- }
- dictionary[pokemon][evolutionType].Add(evolutionIndex);
- }
- else
- {
- // not working.... ;(
- if (dictionary.ContainsKey(pokemon))
- {
- Console.WriteLine($"# {pokemon}");
- foreach (var kvp in dictionary.Where(x=>x.Key==pokemon))
- {
- foreach (var innerKvp in kvp.Value)
- {
- foreach (var item in innerKvp.Value)
- {
- Console.WriteLine($"{innerKvp.Key} -> {item}");
- }
- }
- }
- }
- }
- input = Console.ReadLine();
- }
- // the final printing is working
- foreach (var kvp in dictionary)
- {
- Console.WriteLine($"# {kvp.Key}");
- foreach (var innerKvp in kvp.Value)
- {
- foreach (var listItem in innerKvp.Value.OrderByDescending(x=>x))
- {
- Console.WriteLine($"{innerKvp.Key} -> {listItem}");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement