tanya_zheleva

9

Feb 18th, 2017
65
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.  
  3. namespace ExamPreparation
  4. {
  5.     public sealed class Preparation
  6.     {
  7.         public static void Main()
  8.         {
  9.             string input = Console.ReadLine();
  10.             string key = Console.ReadLine();
  11.  
  12.             while (true)
  13.             {
  14.                 int firstIndex = input.IndexOf(key);
  15.                 int lastIndex = input.LastIndexOf(key);
  16.  
  17.                 if (firstIndex == -1 || lastIndex == -1 || firstIndex == lastIndex || key.Length == 0)
  18.                 {
  19.                     Console.WriteLine("No shake.");
  20.                     Console.WriteLine(input);
  21.  
  22.                     break;
  23.                 }
  24.  
  25.                 input = input.Remove(lastIndex, key.Length);
  26.                 input = input.Remove(firstIndex, key.Length);
  27.                 key = key.Remove(key.Length / 2, 1);
  28.  
  29.                 Console.WriteLine("Shaked it.");
  30.             }
  31.         }
  32.     }
  33. }
Add Comment
Please, Sign In to add comment