Advertisement
AndrianaTodorova

Untitled

Oct 20th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.71 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _02.SoftuniKaraoke
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             List<string> namesOfSingers = Console.ReadLine()
  14.                 .Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries)
  15.                 .ToList();
  16.  
  17.             List<string> songs = Console.ReadLine()
  18.                 .Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries)
  19.                 .ToList();
  20.  
  21.  
  22.             List<Singer> allBullshits = new List<Singer>();
  23.  
  24.             string songSinging = Console.ReadLine();
  25.  
  26.             while(songSinging != "dawn")
  27.             {
  28.                 string[] songList = songSinging.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
  29.  
  30.                 string nameOutput = songList[0];
  31.                 string song = songList[1];
  32.                 string award = songList[2];
  33.  
  34.                 if (namesOfSingers.Any(a => a == nameOutput) && songs.Any(a => a == song))
  35.                 {
  36.  
  37.                     if (!allBullshits.Any(a => a.Name == nameOutput))
  38.                     {
  39.                         var singer = new Singer(nameOutput);
  40.                         allBullshits.Add(singer);
  41.                     }
  42.                     var currentSinger = allBullshits.First(e => e.Name == nameOutput);
  43.  
  44.                     if (!currentSinger.Awards.Any(e => e == award))
  45.                     {
  46.                         currentSinger.Songs.Add(song);
  47.                         currentSinger.Awards.Add(award);
  48.                     }
  49.                 }
  50.                
  51.                 songSinging = Console.ReadLine();
  52.             }
  53.             foreach (var singer in allBullshits.OrderByDescending(e => e.Awards.Count).ThenBy(e => e.Name))
  54.             {
  55.                 Console.WriteLine($"{singer.Name}: { singer.Awards.Count} awards");
  56.  
  57.                 if (!singer.Awards.Any())
  58.                 {
  59.                     Console.WriteLine("No awards");
  60.                     continue;
  61.                 }
  62.  
  63.                 foreach (var award in singer.Awards.OrderBy(e => e))
  64.                 {
  65.                     Console.WriteLine($"--{award}");
  66.                 }  
  67.             }
  68.  
  69.  
  70.         }
  71.  
  72.         class Singer
  73.         {
  74.             public string Name { get; set; }
  75.  
  76.             public List<string> Songs { get; set; }
  77.  
  78.             public List<string> Awards { get; set; }
  79.  
  80.             public Singer(string name)
  81.             {
  82.                 this.Name = name;
  83.                 this.Songs = new List<string>();
  84.                 this.Awards = new List<string>();
  85.             }
  86.         }
  87.     }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement