Advertisement
Guest User

Color Coding

a guest
Mar 17th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace ColorCodingRegEx
  5. {
  6.     class ColorCodingRegEx
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             int numberCouples = int.Parse(Console.ReadLine());            
  11.             for (int n = 0; n < numberCouples; n++)
  12.             {
  13.                 string firstRow = Console.ReadLine();
  14.                 string secondRow = Console.ReadLine();
  15.                 firstRow += " ";
  16.                 secondRow += " ";                
  17.                 string pattern = "^" + firstRow.Replace(") ", " )?") +"$";                
  18.                 if (Regex.IsMatch(secondRow, pattern))
  19.                 {
  20.                     Console.WriteLine("true");
  21.                 }
  22.                 else
  23.                 {
  24.                     Console.WriteLine("false");
  25.                 }
  26.                 GC.Collect();
  27.             }
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement