Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.30 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.  
  7. namespace track_downloader
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string[] blacklisted = Console.ReadLine().Split();
  14.             List<string> filenames = ReadFilenames();
  15.             filenames = filenames
  16.                        .Where(a => ContainsBlackListed(a, blacklisted))
  17.                        .OrderBy(a => a)
  18.                        .ToList();
  19.             Console.WriteLine(string.Join("\r\n", filenames));
  20.         }
  21.  
  22.         private static bool ContainsBlackListed(string a, string[] blacklisted)
  23.         {
  24.             for (int i = 0; i < blacklisted.Length; i++)
  25.             {
  26.                 if (a.Contains(blacklisted[i]))
  27.                 {
  28.                     return false;
  29.                 }
  30.             }
  31.             return true;
  32.         }
  33.  
  34.         private static List<string> ReadFilenames()
  35.         {
  36.             List<string> output = new List<string>();
  37.             string filename = Console.ReadLine();
  38.             while (filename != "end")
  39.             {
  40.                 output.Add(filename);
  41.                 filename = Console.ReadLine();
  42.             }
  43.             return output;
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement