Advertisement
Guest User

Untitled

a guest
Feb 24th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. namespace _3.Snowflake
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. string surface = Console.ReadLine();
  13. string mantle = Console.ReadLine();
  14. string surfaceMantleCore = Console.ReadLine();
  15. mantle = Console.ReadLine();
  16. surface = Console.ReadLine();
  17.  
  18. string pattern1 = @"([^a-zA-Z0-9]+)";
  19. string pattern2 = @"([0-9_]+)";
  20. string pattern3 = @"([^a-zA-Z0-9]+)([0-9_]+)([A-Za-z]+)([0-9_]+)([^a-zA-Z0-9]+)";
  21.  
  22. bool match1 = false;
  23. bool match2 = false;
  24. bool match3 = false;
  25. bool match4 = false;
  26. bool match5 = false;
  27.  
  28.  
  29. MatchCollection matches = Regex.Matches(surface, pattern1);
  30. if (Regex.IsMatch(surface, pattern1))
  31. {
  32. match1 = true;
  33. }
  34.  
  35. MatchCollection matches1 = Regex.Matches(mantle, pattern2);
  36. if(Regex.IsMatch(mantle, pattern2))
  37. {
  38. match2 = true;
  39. }
  40.  
  41. MatchCollection matches2 = Regex.Matches(surfaceMantleCore, pattern3);
  42. var core = 0;
  43.  
  44. if (Regex.IsMatch(surfaceMantleCore, pattern3))
  45. {
  46. match3 = true;
  47. }
  48.  
  49. foreach (Match m in matches2)
  50. {
  51. core = m.Groups[2].Length;
  52. }
  53.  
  54. MatchCollection matches3 = Regex.Matches(mantle, pattern2);
  55. if (Regex.IsMatch(mantle, pattern2))
  56. {
  57. match4 = true;
  58. }
  59.  
  60. MatchCollection matches4 = Regex.Matches(surface, pattern1);
  61. if (Regex.IsMatch(surface, pattern1))
  62. {
  63. match5 = true;
  64. }
  65.  
  66. if (match1 && match2 && match3 && match4 && match5)
  67. {
  68. Console.WriteLine("Valid");
  69. Console.WriteLine("{0}", core);
  70. }
  71. else
  72. {
  73. Console.WriteLine("Invalid");
  74. }
  75. }
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement