Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- namespace _01.Melrah_Shake
- {
- class Program
- {
- static void Main(string[] args)
- {
- var text = Console.ReadLine();
- var pattern = new Regex(Console.ReadLine());
- while (true)
- {
- var patternSTR = pattern.ToString();
- var matches = pattern.Matches(text);
- if (matches.Count < 2 || patternSTR.Length==0)
- {
- break;
- }
- var firstIndex = text.IndexOf(patternSTR);
- text = text.Remove(firstIndex, patternSTR.Length);
- var lastIndex = text.LastIndexOf(patternSTR);
- text = text.Remove(lastIndex, patternSTR.Length);
- patternSTR = patternSTR.Remove(patternSTR.Length / 2, 1);
- pattern = new Regex(patternSTR);
- Console.WriteLine("Shaked it.");
- }
- Console.WriteLine("No shake.");
- Console.WriteLine(text);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement