Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- class Program
- {
- static void Main(string[] args)
- {
- var input = Console.ReadLine().ToList();
- short operations = 0;
- bool isAvail = true;
- while (isAvail)
- {
- if (input.Count <= 1)
- {
- break;
- }
- for (int i = 0; i <= input.Count-2; i++)
- {
- if (input[i] == input[i + 1])
- {
- isAvail = true;
- input.RemoveAt(i);
- input.RemoveAt(i);
- operations++;
- break;
- }
- else
- {
- isAvail = false;
- }
- }
- }
- var result = String.Join("", input);
- if (result == "")
- Console.WriteLine("Empty String");
- else
- Console.WriteLine(result);
- Console.WriteLine($"{operations} operations");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment