Advertisement
MilenaPetkanova

MelrahShake

Oct 30th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. class MelrahShake
  5. {
  6. static void Main()
  7. {
  8. string input = Console.ReadLine();
  9. string pattern = Console.ReadLine();
  10.  
  11. while (Regex.IsMatch(input, pattern + @"(.*)" + pattern)
  12. && input.Length > pattern.Length)
  13. {
  14. Console.WriteLine("Shaked it.");
  15.  
  16. var match = Regex.Match(input, pattern + @"(.*)" + pattern);
  17.  
  18. input = input.Remove(match.Index + match.Length - pattern.Length, pattern.Length);
  19. input = input.Remove(match.Index, pattern.Length);
  20.  
  21. pattern = pattern.Remove(pattern.Length / 2, 1);
  22. if (pattern.Length <= 0)
  23. {
  24. break;
  25. }
  26.  
  27. }
  28.  
  29. Console.WriteLine("No shake.");
  30. Console.WriteLine(input);
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement