Advertisement
grubcho

Playlist with blackList in list with bool

Jun 24th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.50 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. //You will receive a list of blacklisted words (on the same line, separated by one space). On the next lines, you will start receiving //a list of filenames (as strings) until you receive the string β€œend”. Your task is to add the filenames to a list and sort them. //Ignore the tracks which contain the text in the blacklist.
  7. namespace Track_downloader
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             List<string> blackList = Console.ReadLine().Split(' ').ToList();
  14.             List<string> inputList = new List<string>();
  15.             string input = string.Empty;        
  16.             while (input != "end")
  17.             {
  18.                 input = Console.ReadLine();
  19.                 bool notBlackListed = true;
  20.                 foreach (string word  in blackList)
  21.                 {
  22.                     if (input.Contains(word) || input.Contains("end"))
  23.                     {
  24.                         notBlackListed = false;
  25.                         break;  
  26.                     }
  27.                 }
  28.                 if (notBlackListed)
  29.                 {
  30.                     inputList.Add(input);
  31.                 }
  32.                
  33.             }
  34.            
  35.             inputList.Sort();
  36.             for (int i = 0; i < inputList.Count; i++)
  37.             {
  38.                 Console.WriteLine(inputList[i]);
  39.             }
  40.         }        
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement