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();
- List<Singer> allBullshits = new List<Singer>();
- 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.Any(a => a.Name == nameOutput))
- {
- var singer = new Singer(nameOutput);
- allBullshits.Add(singer);
- }
- Singer currentSinger = allBullshits.First(e => e.Name == nameOutput);
- if (!currentSinger.Awards.Any(e => e == award))
- {
- currentSinger.Awards.Add(award);
- }
- }
- songSinging = Console.ReadLine();
- }
- if (!allBullshits.Any())
- {
- Console.WriteLine("No awards");
- return;
- }
- foreach (var singer in allBullshits.OrderByDescending(e => e.Awards.Count).ThenBy(e => e.Name))
- {
- Console.WriteLine($"{singer.Name}: {singer.Awards.Count} awards");
- foreach (var award in singer.Awards.OrderBy(e => e))
- {
- Console.WriteLine($"--{award}");
- }
- }
- }
- class Singer
- {
- public string Name { get; set; }
- public List<string> Awards { get; set; }
- public Singer(string name)
- {
- this.Name = name;
- this.Awards = new List<string>();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement