Guest User

Snowflake

a guest
Jan 6th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 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 Snowflake
  9. {
  10.     class Snowflake
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             string upperSurface = Console.ReadLine();
  15.             string upperMantle = Console.ReadLine();
  16.             string coreInput = Console.ReadLine();
  17.             string lowerMantle = Console.ReadLine();
  18.             string lowerSurface = Console.ReadLine();
  19.  
  20.             string surfacePattern = @"^[^0-9a-zA-Z]+$";
  21.             string mantlePattern = @"^[0-9_]+$";
  22.             string corePattern = @"^[^0-9a-zA-Z]+[0-9_]+([a-zA-Z]+)[0-9_]+[^0-9a-zA-Z]+$";
  23.  
  24.             if (Regex.IsMatch(upperSurface, surfacePattern) && Regex.IsMatch(upperMantle, mantlePattern) && Regex.IsMatch(coreInput, corePattern) && Regex.IsMatch(lowerMantle, mantlePattern) && Regex.IsMatch(lowerSurface, surfacePattern))
  25.             {
  26.                 string core = Regex.Match(coreInput, corePattern).Groups[1].Value;
  27.                
  28.                 Console.WriteLine("Valid");
  29.                 Console.WriteLine(core.Length);
  30.             }
  31.             else
  32.             {
  33.                 Console.WriteLine("Invalid");
  34.             }
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment