Iterate over the string and remove any triplicated letters (e.g. "byeee mmmy friiiennd" becomes "bye my friennd"). You may assume any immediate following same letters are a triplicate.
Answers
Answered by
0
Explanation:
The code for removing the triplates in a string is written below in python language
Code :
def remove_triplates(input_letters, n):
i=0
result = ''
while(True):
result += input_letters [i]
if input_letters [i:i+n] == input_letters [i]*n:
i += n
else:
i += 1
if i >= len(input_letters):
break
return result
Code when simulated :
input_letters = "byeee mmmy friiiennd"
output_letters = remove_ triplates (input_letters, 3)
print(output_letters)
# bye my friennd
Similar questions