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;
- namespace Merlah_Shake
- {
- class MerlahShake
- {
- static void Main()
- {
- string test = Console.ReadLine();
- string key = Console.ReadLine();
- while (true)
- {
- int lastIndex = test.LastIndexOf(key);
- int firstIndex = test.IndexOf(key);
- if (firstIndex != -1 && lastIndex != -1 && firstIndex != lastIndex
- && key.Length > 0)
- {
- Console.WriteLine("Shaked it.");
- test = test.Remove(firstIndex, key.Length);
- lastIndex = test.LastIndexOf(key);
- test = test.Remove(lastIndex, key.Length);
- }
- else
- {
- Console.WriteLine("No shake.");
- Console.WriteLine(test);
- break;
- }
- int indexToRemove = key.Length / 2;
- key = key.Remove(indexToRemove, 1);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment