Advertisement
Guest User

03. Snowflake

a guest
Feb 21st, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.33 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace SnowFlake
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string surfaceRegex = @"[^a-zA-Z\d]+";
  11.             string mantleRegex = @"[\d_]+";
  12.             string coreRegex = @"[A-Za-z]+";
  13.             string full = @"[^a-zA-Z\d]+[\d_]+([A-Za-z]+)[\d_]+[^a-zA-Z\d]+";
  14.  
  15.             string topSurface = Console.ReadLine();
  16.             string topMantle = Console.ReadLine();
  17.             string wtf = Console.ReadLine();
  18.             string bottomMantle = Console.ReadLine();
  19.             string bottomSurface = Console.ReadLine();
  20.  
  21.  
  22.             var firstMatch = Regex.Match(topSurface, surfaceRegex);
  23.             var secondMatch = Regex.Match(topMantle, mantleRegex);
  24.             var wtfMatch = Regex.Match(wtf, full);
  25.             var fourthMatch = Regex.Match(bottomMantle, mantleRegex);
  26.             var fifthMatch = Regex.Match(bottomSurface, surfaceRegex);
  27.  
  28.             if (firstMatch.Success && secondMatch.Success && wtfMatch.Success && fourthMatch.Success && fifthMatch.Success)
  29.             {
  30.                 Console.WriteLine("Valid");
  31.                 Console.WriteLine(wtfMatch.Groups[1].Value.Length);
  32.             }
  33.             else
  34.             {
  35.                 Console.WriteLine("Invalid");
  36.             }
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement