Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Linq;
  4.  
  5. namespace ACMPC
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             try {
  12.                 FilterFile(args.Length>0?new StreamReader(args[0]):Console.In,
  13.                     args.Length>1?new StreamWriter(args[1]):Console.Out);
  14.             } catch(IOException e)
  15.             {
  16.                 Console.Error.WriteLine("IO error encountered: {0}", e.Message);
  17.             }
  18.         }
  19.         static readonly string validChars = "abcdefghijklmnopqrstuvwxyz ";
  20.         static void FilterFile(TextReader input, TextWriter output)
  21.         {
  22.             string val = null;
  23.             while ((val = input.ReadLine().ToLower()) != "end")
  24.                 if (!val.Any(x => !validChars.Contains(x)||
  25.                     (x!=' ' && val.Where(y => y == x).Count() > 1)))
  26.                     output.WriteLine(val);
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement