Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace _04_Sets_and_Dicts_Exer
- {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- public class Startup
- {
- public static void Main()
- {
- List<string> namesOfSingers = Console.ReadLine()
- .Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries)
- .ToList();
- List<string> songs = Console.ReadLine()
- .Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries)
- .ToList();
- Dictionary<string, List<string>> allBullshits = new Dictionary<string, List<string>>();
- string songSinging = Console.ReadLine();
- while (songSinging != "dawn")
- {
- string[] songList = songSinging.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
- string nameOutput = songList[0];
- string song = songList[1];
- string award = songList[2];
- if (namesOfSingers.Any(a => a == nameOutput) && songs.Any(a => a == song))
- {
- if (!allBullshits.ContainsKey(nameOutput))
- {
- allBullshits.Add(nameOutput, new List<string>());
- }
- if (!allBullshits[nameOutput].Any(e => e == award))
- {
- allBullshits[nameOutput].Add(award);
- }
- }
- songSinging = Console.ReadLine();
- }
- if (!allBullshits.Any())
- {
- Console.WriteLine("No awards");
- return;
- }
- foreach (var singer in allBullshits.OrderByDescending(e => e.Value.Count).ThenBy(e => e.Key))
- {
- Console.WriteLine($"{singer.Key}: {singer.Value.Count} awards");
- foreach (var award in singer.Value.OrderBy(e => e))
- {
- Console.WriteLine($"--{award}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement