Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace SoftUni_Karaoke
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> participants = Console.ReadLine()
- .Split(new string[] { ", " },
- StringSplitOptions.RemoveEmptyEntries).ToList();
- List<string> songs = Console.ReadLine()
- .Split(new string[] { ", " },
- StringSplitOptions.RemoveEmptyEntries).ToList();
- string input = Console.ReadLine();
- Dictionary<string, List<string>> awarded =
- new Dictionary<string, List<string>>();
- while (input != "dawn")
- {
- string[] parts = input
- .Split(new string[] { ", " },
- StringSplitOptions.RemoveEmptyEntries);
- string name = parts[0];
- string song = parts[1];
- string award = parts[2];
- if (!participants.Any(p => p == name) || !songs.Any(s => s == song))
- {
- input = Console.ReadLine();
- continue;
- }
- if (!awarded.ContainsKey(name))
- {
- awarded.Add(name, new List<string>());
- }
- awarded[name].Add(award);
- input = Console.ReadLine();
- }
- if (awarded.Count == 0)
- {
- Console.WriteLine("No awards");
- }
- foreach (var singer in awarded
- .OrderByDescending(x => x.Value.Distinct()
- .ToList().Count)
- .ThenBy(x => x.Key))
- {
- List<string> awards = singer.Value.Distinct().ToList();
- Console.WriteLine($"{singer.Key}: {awards.Count} awards");
- foreach (string award in awards.OrderBy(x => x))
- {
- Console.WriteLine($"--{award}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement