Advertisement
martyz

RainAir

Dec 10th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.82 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace RainAir
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string input = Console.ReadLine();
  14.             SortedDictionary<string, List<int>> dict = new SortedDictionary<string, List<int>>();
  15.  
  16.             while (input != "I believe I can fly!")
  17.             {
  18.                 string[] arr = input.Split(' ').ToArray();
  19.  
  20.                 if (!arr[0].Contains(' ') || !arr[0].Contains('='))
  21.                 {
  22.                     if (arr[1] != "=")
  23.                     {
  24.                         string customerName = arr[0];
  25.                         if (!dict.Keys.Contains(customerName))
  26.                         {
  27.                             dict.Add(customerName, new List<int>());
  28.                             dict[customerName].AddRange(arr.Skip(1).Select(x => int.Parse(x)).ToArray());
  29.                         }
  30.                         else
  31.                         {
  32.                             dict[customerName].AddRange(arr.Skip(1).Select(x => int.Parse(x)).ToArray());
  33.                         }
  34.                     }
  35.                     else
  36.                     {
  37.                         dict[arr[0]].Clear();
  38.                         dict[arr[0]].AddRange(dict[arr[2]]);
  39.                     }
  40.                 }
  41.                 input = Console.ReadLine();
  42.  
  43.             }
  44.             //var ordered = dict.OrderByDescending(x => x.Value.Count).ThenBy(y => y.Key);
  45.  
  46.             foreach (var item in dict.OrderByDescending(x => x.Value.Count))
  47.             {
  48.                 Console.Write("#" + item.Key + " ::: ");
  49.                 item.Value.Sort();
  50.                 Console.WriteLine(string.Join(", ", item.Value));
  51.             }
  52.  
  53.  
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement