Delete the Repeats
If you're viewing this on the Challenge Zone website, you can click here to open the challenge in a new tab.
Scenario
A new app has been developed that recongizes words containing repeated characters that are adjacent to each other. This app automatically detects these repeated characters and instantly deletes them from the word, creating new interesting words.
Task
Given a String
containing characters from the alphabet [a-z, A-Z], write an alterCharacters
function to delete all repeating characters that are adjacent to each other and return the total number of deleted characters.
alterCharacters
The alterCharacters
function should accept a String
argument and return an Integer
value.
Sample Results
Your function should work for any String
argument. DO NOT HARDCODE!