Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _3.Snowflake
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, Dictionary<string, int>> dict = new Dictionary<string, Dictionary<string, int>>();
- string command = Console.ReadLine();
- while(command != "Once upon a time")
- {
- string[] text = command.Split(new char[] { '<', ':', '>', ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
- string dwarfName = text[0];
- string dwarfHatColor = text[1];
- int dwarfPhysics = int.Parse(text[2]);
- if(dict.ContainsKey(dwarfHatColor) == false)
- {
- Dictionary<string, int> helper = new Dictionary<string, int>();
- helper.Add(dwarfName, dwarfPhysics);
- dict.Add(dwarfHatColor, helper);
- }
- else if(dict[dwarfHatColor].ContainsKey(dwarfName) == false)
- {
- dict[dwarfHatColor].Add(dwarfName, dwarfPhysics);
- }
- if (dict[dwarfHatColor][dwarfName] < dwarfPhysics)
- {
- dict[dwarfHatColor][dwarfName] = dwarfPhysics;
- }
- command = Console.ReadLine();
- }
- foreach (var pair in dict.OrderByDescending(x => x.Value.Values.Sum()))
- {
- foreach (var item in pair.Value)
- {
- Console.WriteLine("({0}) {1} <-> {2}", pair.Key , item.Key, item.Value);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement