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;
- namespace Exerciese
- {
- class Program
- {
- static void Main(string[] args)
- {
- var participansInKaraoke = Console.ReadLine().Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList().Select(x => x.Trim());
- var songsInKaraoke = Console.ReadLine().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList().Select(x => x.Trim());
- var peopleAwards = new Dictionary<string, HashSet<string>>();
- while (true)
- {
- var tokens = Console.ReadLine().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); ;
- if (tokens[0] == "dawn")
- {
- break;
- }
- var participan = tokens[0].Trim();
- var song = tokens[1].Trim();
- var award = tokens[2];
- if (participansInKaraoke.Contains(participan) && songsInKaraoke.Contains(song))
- {
- if (!peopleAwards.ContainsKey(participan))
- {
- peopleAwards[participan] = new HashSet<string>();
- }
- peopleAwards[participan].Add(award);
- }
- else
- {
- continue;
- }
- }
- if (peopleAwards.Keys.Count == 0)
- {
- Console.WriteLine("No awards");
- }
- else
- {
- foreach (var item in peopleAwards.Where(x => x.Value.Count > 0).OrderByDescending(x => x.Key).ThenBy(x => x.Key).ThenBy(x => x.Value))
- {
- Console.WriteLine($"{item.Key}: {item.Value.Count} awards");
- foreach (var i in item.Value)
- {
- Console.WriteLine($"--{i.Trim()}");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement