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.Threading.Tasks;
- using System.Text.RegularExpressions;
- //09. Melrah Shake
- namespace MelrahShake
- {
- class MelrahShake
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine().Trim();
- string pattern = Console.ReadLine();
- bool canShake = true;
- while (canShake)
- {
- int matchCount = Regex.Matches(input, pattern).Count;
- if (matchCount >= 2)
- {
- int indxFirst = input.IndexOf(pattern);
- input = input.Remove(indxFirst, pattern.Length);
- int indxLast = input.LastIndexOf(pattern);
- input = input.Remove(indxLast, pattern.Length);
- Console.WriteLine("Shaked it.");
- if (pattern.Length >= 2)
- {
- pattern = pattern.Remove(pattern.Length / 2, 1);
- }
- else
- {
- Console.WriteLine("No shake.");
- break;
- }
- }
- else
- {
- Console.WriteLine("No shake.");
- canShake = false;
- break;
- }
- }
- Console.WriteLine(input);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement