Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int count = int.Parse(Console.ReadLine());
- Dictionary<string, Dictionary<string, int>> wardrobe = new Dictionary<string, Dictionary<string, int>>();
- for (int i = 0; i < count; i++)
- {
- string[] input = Console.ReadLine().Split(new string[] { "->", " "} , StringSplitOptions.RemoveEmptyEntries).ToArray();
- string[] clothes = input[1].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
- Dictionary<string, int> clothesAll = new Dictionary<string, int>();
- if (wardrobe.ContainsKey(input[0]) == false)
- {
- for (int j = 0; j < clothes.Length; j++)
- {
- if (clothesAll.ContainsKey(clothes[j]) == false)
- {
- clothesAll.Add(clothes[j], 1);
- }
- else
- {
- clothesAll[clothes[j]] += 1;
- }
- }
- wardrobe.Add(input[0], clothesAll);
- }
- else
- {
- foreach (var item in clothes)
- {
- if (wardrobe[input[0]].ContainsKey(item) == false)
- {
- wardrobe[input[0]].Add(item, 1);
- }
- else
- {
- wardrobe[input[0]][item]++;
- }
- }
- }
- }
- string[] inputNeeded = Console.ReadLine().Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries).ToArray();
- foreach (var color in wardrobe)
- {
- Console.WriteLine($"{color.Key} clothes:");
- foreach (var item in color.Value)
- {
- if (color.Key == inputNeeded[0] && item.Key == inputNeeded[1])
- {
- Console.WriteLine($"* {item.Key} - {item.Value} (found!)");
- }
- else
- {
- Console.WriteLine($"* {item.Key} - {item.Value}");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement