Guest User

Untitled

a guest
Mar 6th, 2018
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. class Program
  5. {
  6. static void Main(string[] args)
  7. {
  8. var input = Console.ReadLine().ToList();
  9. short operations = 0;
  10. bool isAvail = true;
  11.  
  12. while (isAvail)
  13. {
  14. if (input.Count <= 1)
  15. {
  16. break;
  17. }
  18. for (int i = 0; i <= input.Count-2; i++)
  19. {
  20. if (input[i] == input[i + 1])
  21. {
  22. isAvail = true;
  23. input.RemoveAt(i);
  24. input.RemoveAt(i);
  25. operations++;
  26. break;
  27. }
  28. else
  29. {
  30. isAvail = false;
  31. }
  32. }
  33. }
  34. var result = String.Join("", input);
  35. if (result == "")
  36. Console.WriteLine("Empty String");
  37. else
  38. Console.WriteLine(result);
  39. Console.WriteLine($"{operations} operations");
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment