Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _3._3_Nikulden_s_meals
- {
- class Program
- {
- static void Main(string[] args)
- {
- string command;
- Dictionary<string, List<string>> guestMenue = new Dictionary<string, List<string>>();
- int count = 0;
- while ((command = Console.ReadLine()) != "Stop")
- {
- string[] commandSplit = command.Split("-", StringSplitOptions.RemoveEmptyEntries).ToArray();
- string likeUnlike = commandSplit[0];
- string guests = commandSplit[1];
- string meal = commandSplit[2];
- if (likeUnlike == "Like")
- {
- if (!guestMenue.ContainsKey(guests))
- {
- guestMenue.Add(guests, new List<string>());
- }
- if (!guestMenue.ContainsKey(meal))
- {
- guestMenue[guests].Add(meal);
- }
- }
- else if (likeUnlike == "Unlike")
- {
- if (!guestMenue.ContainsKey(guests))
- {
- Console.WriteLine($"{guests} is not at the party.");
- }
- else if (!guestMenue[guests].Contains(meal))
- {
- Console.WriteLine($"{guests} doesn't have the {meal} in his/her collection.");
- }
- else
- {
- guestMenue[guests].Remove(meal);
- Console.WriteLine($"{guests} doesn't like the {meal}.");
- count++;
- }
- }
- }
- guestMenue = guestMenue.OrderByDescending(kvp => kvp.Value.Count).ThenBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
- foreach (var kvp in guestMenue)
- {
- Console.WriteLine($"{kvp.Key}: {string.Join(",", kvp.Value)}");
- }
- Console.WriteLine($"Unliked meals: {count}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement