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;
- using System.Text.RegularExpressions;
- namespace ConsoleApplication15
- {
- class Program
- {
- static void Main(string[] args)
- {
- var input = Console.ReadLine();
- var list = new Dictionary<string, Pokemon>();
- while (input != "wubbalubbadubdub")
- {
- var tempInput = input.Split(new string[] { " -> " }, StringSplitOptions.RemoveEmptyEntries).ToArray();
- if (tempInput.Length != 1)
- {
- var evolName = tempInput[1];
- var evolIndex = int.Parse(tempInput[2]);
- if (!list.ContainsKey(tempInput[0]))
- {
- list[tempInput[0]] = new Pokemon();
- }
- list[tempInput[0]].name = tempInput[0];
- if (list[tempInput[0]].evolution == null)
- {
- list[tempInput[0]].evolution = new List<Evolutions>();
- list[tempInput[0]].evolution.Add(new Evolutions { nameOfEv = evolName, evolIndex = evolIndex });
- }
- else
- list[tempInput[0]].evolution.Add(new Evolutions { nameOfEv = evolName, evolIndex = evolIndex });
- }
- else
- {
- foreach (var item in list.Values)
- {
- if (item.name == tempInput[0])
- {
- Console.WriteLine("# "+item.name);
- foreach (var item2 in item.evolution)
- {
- Console.WriteLine($"{item2.nameOfEv} <-> {item2.evolIndex}");
- }
- }
- }
- }
- input = Console.ReadLine();
- }
- foreach (var item in list.Values)
- {
- Console.WriteLine("# "+item.name);
- foreach (var item2 in item.evolution.OrderByDescending(x => x.evolIndex))
- {
- Console.WriteLine($"{item2.nameOfEv} <-> {item2.evolIndex}");
- }
- }
- }
- }
- class Pokemon
- {
- public string name { get; set; }
- public List<Evolutions> evolution { get; set; }
- }
- class Evolutions
- {
- public string nameOfEv { get; set; }
- public int evolIndex { get; set; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement