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;
- class SongAward
- {
- public string Song { get; set; }
- public string Award { get; set; }
- }
- namespace _02_SoftUni_Karaoke
- {
- class Program
- {
- static void Main(string[] args)
- {
- var participantsList = Console.ReadLine().Split(',').Select(x => x.Trim()).ToList();
- var songList = Console.ReadLine().Split(',').Select(x => x.Trim()).ToList();
- var result = new Dictionary<string, List<SongAward>>();
- var input = Console.ReadLine();
- while (input != "dawn")
- {
- var candidateToSingList = input.Split(',').Select(x => x.Trim()).ToList();
- if (candidateToSingList.Count != 3)
- {
- input = Console.ReadLine();
- continue;
- }
- var participantName = candidateToSingList[0];
- var song = candidateToSingList[1];
- var award = candidateToSingList[2];
- if (!participantsList.Contains(participantName) || !songList.Contains(song))
- {
- input = Console.ReadLine();
- continue;
- }
- var newSongAward = new SongAward();
- newSongAward.Song = song;
- newSongAward.Award = award;
- if (!result.ContainsKey(participantName))
- {
- result.Add(participantName, new List<SongAward>());
- }
- result[participantName].Add(newSongAward);
- input = Console.ReadLine();
- Console.WriteLine();
- }
- if (result.Count == 0)
- {
- Console.WriteLine("No awards");
- }
- foreach (var item in result)
- {
- foreach (var award in item.Value)
- {
- var awardCount = award.Award.Distinct().Count();
- var awardList = award.Award.Distinct().OrderBy(n => n).ToList();
- Console.WriteLine($"Vankata: {awardCount} awards");
- foreach (var a in awardList)
- {
- Console.WriteLine($"--{a}");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement