Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _2._1_On_the_Way_to_Annapurna
- {
- class Program
- {
- static void Main()
- {
- Dictionary<string, List<string>> stores = new Dictionary<string, List<string>>();
- while (true)
- {
- string commands = Console.ReadLine();
- if (commands == "END")
- {
- break;
- }
- string[] commandArgs = commands.Split("->");
- string command = commandArgs[0];
- string store = commandArgs[1];
- if (command == "Add")
- {
- List<string> items = commandArgs[2].Split(",").ToList();
- if (!stores.ContainsKey(store))
- {
- stores.Add(store, new List<string>());
- foreach (var item in items)
- {
- stores[store].Add(item);
- }
- }
- else
- {
- foreach (var item in items)
- {
- stores[store].Add(item);
- }
- }
- }
- else if (command == "Remove")
- {
- if (stores.ContainsKey(store))
- {
- stores.Remove(store);
- }
- }
- }
- Console.WriteLine("Stores list:");
- foreach (var store in stores
- .OrderByDescending(x => x.Value.Count)
- .ThenByDescending(x => x.Key))
- {
- Console.WriteLine($"{store.Key}");
- foreach (var item in store.Value)
- {
- Console.WriteLine($"<<{item}>>");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement