Advertisement
miroLLL

SoftUni-Karaoke

Mar 2nd, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.18 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. namespace _02Problem_SoftUniKaraoke
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             string[] participants = Console.ReadLine().Split(',').Select(p => p.Trim()).ToArray();
  13.             string[] songsList = Console.ReadLine().Split(',').Select(s => s.Trim()).ToArray();
  14.  
  15.             string name = string.Empty;
  16.             string song = string.Empty;
  17.             string award = string.Empty;
  18.  
  19.             var performingShowInfo = new SortedDictionary<string, List<string>>();
  20.  
  21.             string[] performingShow = Console.ReadLine().Split(',').Select(pS => pS.Trim()).ToArray();
  22.  
  23.             if (performingShow[0] == "dawn" && performingShow.Length == 1)
  24.             {
  25.                 Console.WriteLine("No awards");
  26.                 Environment.Exit(0);
  27.             }
  28.  
  29.             while (performingShow[0] != "dawn")
  30.             {
  31.                 name = performingShow[0];
  32.                 song = performingShow[1];
  33.                 award = performingShow[2];
  34.  
  35.                 if (participants.Contains(name) && songsList.Contains(song))
  36.                 {
  37.                     if (performingShowInfo.ContainsKey(name) == false)
  38.                     {
  39.                         performingShowInfo.Add(name, new List<string>());
  40.                         performingShowInfo[name].Add(award);
  41.                     }
  42.  
  43.                     if (performingShowInfo[name].Contains(award) == false)
  44.                     {
  45.                         performingShowInfo[name].Add(award);
  46.                     }
  47.                 }
  48.                
  49.                 performingShow = Console.ReadLine().Split(',').Select(pS => pS.Trim()).ToArray();
  50.             }
  51.  
  52.  
  53.             foreach (var participant in performingShowInfo.OrderByDescending(p => p.Value.Count()))
  54.             {
  55.                 Console.WriteLine($"{participant.Key}: {participant.Value.Count()} awards");
  56.  
  57.                 foreach (var a in participant.Value.OrderBy(x => x))
  58.                 {
  59.                     Console.WriteLine($"--{a}");
  60.                 }
  61.             }
  62.         }
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement