Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace _06._Wardrobe
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- var wardrobe = new Dictionary<string, Dictionary<string, int>>();
- for (int i = 0; i < n; i++)
- {
- string[] colorClothes = Console.ReadLine().Split(" -> ");
- string color = colorClothes[0];
- string[] clothes = colorClothes[1].Split(",");
- if (!wardrobe.ContainsKey(color))
- {
- wardrobe.Add(color, new Dictionary<string, int>());
- for (int c = 0; c < clothes.Length; c++)
- {
- string currItem = clothes[c];
- if (!wardrobe[color].ContainsKey(currItem))
- {
- wardrobe[color].Add(currItem, new int());
- wardrobe[color][currItem]++;
- }
- else
- {
- wardrobe[color][currItem]++;
- }
- }
- }
- else
- {
- for (int c = 0; c < clothes.Length; c++)
- {
- string currItem = clothes[c];
- if (!wardrobe[color].ContainsKey(currItem))
- {
- wardrobe[color].Add(currItem, new int());
- wardrobe[color][currItem]++;
- }
- else
- {
- wardrobe[color][currItem]++;
- }
- }
- }
- }
- string[] colorItem = Console.ReadLine().Split(new string[] {" "}, StringSplitOptions.RemoveEmptyEntries);
- string colorOf = colorItem[0];
- string item = colorItem[1];
- foreach (var color in wardrobe)
- {
- Console.WriteLine($"{color.Key} clothes:");
- foreach (var dress in color.Value)
- {
- if (color.Key.Equals(colorOf) && dress.Key.Equals(item)) //old: if (color.Key.Contains(colorOf) && dress.Key.Contains(item))
- {
- Console.WriteLine($"* {dress.Key} - {dress.Value} (found!)");
- }
- else
- {
- Console.WriteLine($"* {dress.Key} - {dress.Value}");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement