Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Shellbound
- {
- class Program
- {
- static void Main(string[] args)
- {
- var topics = new Dictionary<string, List<string>>();
- List <string> input = Console.ReadLine().Split(new[] { ' ', ',', '-', '>' }, StringSplitOptions.RemoveEmptyEntries).ToList();
- while (input[0] != "filter")
- {
- if (topics.ContainsKey(input[0]) == false)
- {
- topics[input[0]] = new List<string>();
- }
- for (int i = 1; i < input.Count; i++)
- {
- if (topics[input[0]].Contains(input[i]) == false)
- {
- topics[input[0]].Add(input[i]);
- }
- }
- input = Console.ReadLine().Split(new[] { ' ', ',', '-', '>' }, StringSplitOptions.RemoveEmptyEntries).ToList();
- }
- List<string> filterWords = Console.ReadLine().Split(',').ToList();
- foreach (var item in topics)
- {
- bool isValid = true;
- for (int i = 1; i < input.Count; i++)
- {
- for (int j = i - 1; j < filterWords.Count; j++)
- {
- if (input[i] != filterWords[j])
- {
- isValid = false;
- }
- }
- }
- if (isValid == false)
- {
- topics.Remove(item.Key);
- }
- }
- foreach (var item in topics)
- {
- List<string> result = item.Value.Select(x => "#" + x).ToList();
- Console.WriteLine($"{item.Key} | {string.Join(",", result)}");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment