sivancheva

PhoenixGrid

Oct 27th, 2017
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Threading.Tasks;
  7.  
  8. namespace _03_PhoenixGrid
  9. {
  10. class PhoenixGrid
  11. {
  12. static void Main(string[] args)
  13. {
  14.  
  15. var input = Console.ReadLine();
  16. var pattern = new Regex(@"^([^_\s]{3})(\.[^_\s]{3})*$");
  17. var result = new List<string>();
  18.  
  19. while (input != "ReadMe")
  20. {
  21. var match = pattern.Match(input);
  22.  
  23. if (!match.Success)
  24. {
  25. Console.WriteLine("NO");
  26. input = Console.ReadLine();
  27. continue;
  28. }
  29. else
  30. {
  31. var matchesString = match.ToString();
  32. string s1 = matchesString.Substring(0, matchesString.Length/2);
  33. string s2 = matchesString.Substring((matchesString.Length / 2 +1), matchesString.Length - (matchesString.Length / 2 + 1));
  34.  
  35. char[] charArray = s2.ToCharArray();
  36. Array.Reverse(charArray);
  37. string reversedS2 = new string(charArray);
  38.  
  39.  
  40. if (s1.Equals(reversedS2))
  41. {
  42. Console.WriteLine("YES");
  43.  
  44. }
  45. else
  46. {
  47. Console.WriteLine("NO");
  48.  
  49. }
  50.  
  51. }
  52. input = Console.ReadLine();
  53. }
  54. }
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment