Advertisement
Guest User

Untitled

a guest
Feb 24th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 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. foreach (var match in matches)
  31. {
  32. if (match == matches)
  33. {
  34. match1 = true;
  35. }
  36. }
  37.  
  38. MatchCollection matches1 = Regex.Matches(mantle, pattern2);
  39. foreach (var match in matches1)
  40. {
  41. if (match == matches1)
  42. {
  43. match2 = true;
  44. }
  45. }
  46.  
  47. MatchCollection matches2 = Regex.Matches(surfaceMantleCore, pattern3);
  48. var core = 0;
  49. foreach (var match in matches2)
  50. {
  51. if (match == matches2)
  52. {
  53. match3 = true;
  54. }
  55. }
  56. foreach (Match m in matches2)
  57. {
  58. core = m.Groups[2].Length;
  59. }
  60.  
  61. MatchCollection matches3 = Regex.Matches(mantle, pattern2);
  62. foreach (var match in matches3)
  63. {
  64. if (match == matches3)
  65. {
  66. match4 = true;
  67. }
  68. }
  69.  
  70. MatchCollection matches4 = Regex.Matches(surface, pattern1);
  71. foreach (var match in matches4)
  72. {
  73. if(match == matches4)
  74. {
  75. match5 = true;
  76. }
  77. }
  78.  
  79. if (match1 && match2 && match3 && match4 && match5)
  80. {
  81. Console.WriteLine("Valid");
  82. Console.WriteLine("{0}", core);
  83. }
  84. else
  85. {
  86. Console.WriteLine("Invalid");
  87. }
  88. }
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement