simeon3000

03. Phoenix Grid

Sep 6th, 2017
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1.             Regex pattern = new Regex(@"^([^\s_]{3}\.)+([^\s_]{3})*$");
  2.  
  3.             string input = Console.ReadLine();
  4.             while (input != "ReadMe")
  5.             {                
  6.                 if (pattern.IsMatch(input) || input.Length == 3)
  7.                 {
  8.                     bool isPalindrome = true;
  9.  
  10.                     for (int i = 0; i < input.Length / 2; i++)
  11.                     {
  12.                         if (input[i] != input[input.Length - 1 - i])
  13.                         {
  14.                             Console.WriteLine("NO");
  15.                             isPalindrome = false;
  16.                             break;
  17.                         }
  18.                     }
  19.                     if (isPalindrome)
  20.                     {
  21.                         Console.WriteLine("YES");
  22.                     }                    
  23.                 }
  24.  
  25.                 else
  26.                 {
  27.                     Console.WriteLine("NO");
  28.                 }
  29.  
  30.                 input = Console.ReadLine();
  31.             }
Advertisement
Add Comment
Please, Sign In to add comment