damyan91

Untitled

Jun 12th, 2017
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7.  
  8. namespace Merlah_Shake
  9. {
  10. class MerlahShake
  11. {
  12. static void Main()
  13. {
  14. string test = Console.ReadLine();
  15. string key = Console.ReadLine();
  16.  
  17. while (true)
  18. {
  19. int lastIndex = test.LastIndexOf(key);
  20. int firstIndex = test.IndexOf(key);
  21.  
  22. if (firstIndex != -1 && lastIndex != -1 && firstIndex != lastIndex
  23. && key.Length > 0)
  24. {
  25. Console.WriteLine("Shaked it.");
  26. test = test.Remove(firstIndex, key.Length);
  27. lastIndex = test.LastIndexOf(key);
  28. test = test.Remove(lastIndex, key.Length);
  29. }
  30. else
  31. {
  32. Console.WriteLine("No shake.");
  33. Console.WriteLine(test);
  34. break;
  35. }
  36.  
  37. int indexToRemove = key.Length / 2;
  38. key = key.Remove(indexToRemove, 1);
  39. }
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment