stefan1919

hackerRankPANCODE

Oct 2nd, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 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. using System.Text.RegularExpressions;
  7.  
  8. namespace ConsoleApplication3
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             int n = int.Parse(Console.ReadLine());
  15.             int counter = 0;
  16.             string pattern = @"[A-Z]{5}[0-9]{4}[A-Z]";
  17.             Regex regex = new Regex(pattern);
  18.             List<string> output = new List<string>();
  19.             do
  20.             {
  21.                 string input = Console.ReadLine();
  22.                 if (regex.IsMatch(input) == true)
  23.                 {
  24.                     output.Add("YES");
  25.                 }
  26.                 else
  27.                 {
  28.                     output.Add("NO");
  29.                 }
  30.                 counter++;
  31.             } while (counter < n);
  32.             foreach (var item in output)
  33.     {
  34.         Console.WriteLine(item);
  35.     }
  36.         }
  37.     }
  38. }
Add Comment
Please, Sign In to add comment