Advertisement
YavorGrancharov

PhoenixGrid

Jan 4th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace PhoenixGrid
  5. {
  6.     class MainClass
  7.     {
  8.         public static void Main(string[] args)
  9.         {
  10.             string input = Console.ReadLine();
  11.  
  12.             string pattern = @"^([^\s_]{3}\.)+([^\s_]{3})*$";
  13.  
  14.             Regex regex = new Regex(pattern);
  15.  
  16.             while (input != "ReadMe")
  17.             {
  18.                 Match message = regex.Match(input);
  19.  
  20.                 if (message.Success || input.Length == 3)
  21.                 {
  22.                     bool isPalindrome = true;
  23.                     for (int i = 0; i < input.Length / 2; i++)
  24.                     {
  25.                         if (input[i] != input[input.Length - 1 - i])
  26.                         {
  27.                             Console.WriteLine("NO");
  28.                             isPalindrome = false;
  29.                             break;
  30.                         }
  31.                     }
  32.                     if (isPalindrome)
  33.                     {
  34.                         Console.WriteLine("YES");
  35.                     }              
  36.                 }
  37.                 else
  38.                 {
  39.                     Console.WriteLine("NO");
  40.                 }
  41.                 input = Console.ReadLine();
  42.             }
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement