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