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