Advertisement
Mike_Goodman92

Untitled

Oct 24th, 2017
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 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 Problem_2.SoftUni_Karaoke
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. List<string> ListOfValidParticipants = new List<string>();
  14. List<string> ListOfValidSongs = new List<string>();
  15.  
  16. Dictionary<string, List<string>> validAwardWinnersList = new Dictionary<string, List<string>>();
  17.  
  18. string[] getParticipants = Console.ReadLine().Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
  19.  
  20. if (getParticipants.Length == 0)
  21. {
  22. Console.WriteLine("No awards");
  23. return;
  24. }
  25.  
  26. ListOfValidParticipants = addToList(getParticipants);
  27.  
  28. string[] getSongList = Console.ReadLine().Split(new string[] { ", " }, StringSplitOptions.None);
  29.  
  30. if (getSongList.Length == 0)
  31. {
  32. Console.WriteLine("No awards");
  33. return;
  34. }
  35.  
  36. ListOfValidSongs = addToList(getSongList);
  37.  
  38.  
  39. string contastantAgenda = Console.ReadLine();
  40.  
  41. while (contastantAgenda != "dawn")
  42. {
  43. string[] nameMusicAwardInfo = contastantAgenda.Split(new string[] { ", " }, StringSplitOptions.None);
  44.  
  45. if (nameMusicAwardInfo.Length != 3)
  46. {
  47. contastantAgenda = Console.ReadLine();
  48. continue;
  49. }
  50.  
  51. string participantName = nameMusicAwardInfo[0];
  52. string musicNumber = nameMusicAwardInfo[1];
  53. string award = nameMusicAwardInfo[2];
  54.  
  55.  
  56. if (ListOfValidParticipants.Any(x => x == participantName) && ListOfValidSongs.Any(x => x == musicNumber))
  57. {
  58. if (!validAwardWinnersList.ContainsKey(participantName))
  59. {
  60. validAwardWinnersList[participantName] = new List<string>();
  61. }
  62.  
  63. validAwardWinnersList[participantName].Add(award);
  64.  
  65. }
  66.  
  67. contastantAgenda = Console.ReadLine();
  68. }
  69.  
  70. // OutPut:
  71.  
  72. if (validAwardWinnersList.Count == 0)
  73. {
  74. Console.WriteLine("No awards");
  75. return;
  76. }
  77.  
  78. foreach (var participant in validAwardWinnersList.OrderByDescending(x => x.Value.Distinct().Count()).ThenBy(x => x.Key).Distinct())
  79. {
  80. Console.WriteLine($"{participant.Key}: {participant.Value.Distinct().Count()} awards");
  81.  
  82. foreach (var awards in participant.Value.OrderBy(x => x).Distinct())
  83. {
  84. Console.WriteLine($"--{awards}");
  85. }
  86.  
  87. }
  88.  
  89.  
  90.  
  91.  
  92. }
  93.  
  94. private static List<string> addToList(string[] stuff)
  95. {
  96. List<string> justAList = new List<string>();
  97.  
  98. foreach (var item in stuff)
  99. {
  100. justAList.Add(item);
  101. }
  102. return justAList;
  103. }
  104.  
  105.  
  106. }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement