Repeat until string s is empty.
If there are two or more consecutive letters from the beginning of s
・Define n as the number of consecutive pieces.
・Display 'ns' and delete n characters from the beginning.
If two or more characters are not consecutive
・Memorize how many characters are not consecutive and display '-ns'.
・Then remove ns from the string.
Example.
input = 'abcaaaaaaaaaaaaaab'
output = '-3abc12a-1b'
input = 'AaAaAAAAa'
output = '-4AaAa4A-1a'
If you are familiar with the algorithm, it would be helpful to know.