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.RegularExpressions;
- namespace RegEx.cs
- {
- class Program
- {
- static void Main(string[] args)
- {
- var input = Console.ReadLine();
- var pokemons = new List<string>();
- var evolution = new Dictionary<string, List<string>>();
- var power = new Dictionary<string, List<int>>();
- while (input != "wubbalubbadubdub")
- {
- string[] danni = Regex.Split(input, @" -> ");
- if (danni.Length > 1)
- {
- if (evolution.ContainsKey(danni[0]))
- {
- evolution[danni[0]].Add(danni[1]);
- power[danni[0]].Add(int.Parse(danni[2]));
- }
- else
- {
- var cPower = new List<int>();
- var cEvolution = new List<string>();
- cEvolution.Add(danni[1]);
- cPower.Add(int.Parse(danni[2]));
- evolution.Add(danni[0], cEvolution);
- power.Add(danni[0], cPower);
- }
- }
- if(danni.Length==1 && evolution.ContainsKey(danni[0]))
- {
- Console.WriteLine($"# {danni[0]}");
- for (int i = 0; i < evolution[danni[0]].Count; i++)
- {
- Console.WriteLine($"{evolution[danni[0]][i]} <-> {power[danni[0]][i]}");
- }
- }
- input = Console.ReadLine();
- }
- foreach (var item in power)
- {
- for(int i = 0; i < item.Value.Count; i++)
- {
- for (int x = i+1; x < item.Value.Count; x++)
- {
- if(item.Value[i]<item.Value[x])
- {
- int num = item.Value[i];
- item.Value[i] = item.Value[x];
- item.Value[x] = num;
- string text = evolution[item.Key][i];
- evolution[item.Key][i] = evolution[item.Key][x];
- evolution[item.Key][x] = text;
- }
- }
- }
- }
- foreach (var x in evolution)
- {
- Console.WriteLine($"# {x.Key}");
- for (int i = 0; i < x.Value.Count; i++)
- {
- Console.WriteLine($"{evolution[x.Key][i]} <-> {power[x.Key][i]}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement