Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace ArrivingInKathmandu
- {
- class Program
- {
- static void Main(string[] args)
- {
- var storesAndItems = new Dictionary<string, List<string>>();
- string commands;
- while ((commands = Console.ReadLine()) != "END")
- {
- List<string> splitedCommand = commands.Split("->").ToList();
- string toDo = splitedCommand[0];
- if (toDo == "Add")
- {
- string store = splitedCommand[1];
- List<string> items = splitedCommand[2].Split(",").ToList();
- if (!storesAndItems.ContainsKey(store))
- {
- storesAndItems[store] = new List<string>();
- }
- foreach (var item in items)
- {
- storesAndItems[store].Add(item);
- }
- }
- else if (toDo == "Remove")
- {
- string storeToRemove = splitedCommand[1];
- if (storesAndItems.ContainsKey(storeToRemove))
- {
- storesAndItems.Remove(storeToRemove);
- }
- }
- }
- Console.WriteLine("Stores list: ");
- foreach (var store in storesAndItems.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