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