Question: I need help with the following in C programming. The ancient and mysterious Apaxian civilization, which we most certainly did not make up, continues to
I need help with the following in C programming.
The ancient and mysterious Apaxian civilization, which we most certainly did not make up, continues to confound the researchers at the Oriental Institute. It turns out that the Apaxians had a peculiar naming system: the more letters in your name, the higher your status in society. So, in Apaxian society, bob was probably a lowly servant, and bobapalaxiamethostenes was likely a High Priest or Minister. Even more than that, Apaxians valued the number of adjacent letters that were the same in a name. So, while bob continues to be an unimpressive name, boooooooooob probably elicited cheers and applause wherever he went.
Unfortunately, this makes the task of reading Apaxian scrolls very cumbersome, specially when you consider that a particularly famous Apaxian queen had ten thousand consecutive as in her name. Legend has it that she was already two years old by the time the Royal Herald finished announcing her birth.
To make the Oriental Institutes life easier, the Department of Computer Science has offered to convert the Apaxian scrolls into a more readable format. Specifically, we will be taking Apaxian names and replacing all consecutive runs of the same letter by a single instance of such letter.
So, for example, the compact version of boooob would be bob, where the four consecutive os have been replaced with a single o. Similarly, the compact version of bbbooobbb would also be bob. On the other hand, the compact version of bob is still bob.
Input
The input contains a single name. Each name contains only lowercase letters (az), no whitespace, a minimum length of 1 character, and a maximum length of 250 characters.
Output
The output contains the compact version of the name: any time the same letter appears two or more times in sequence, it must be replaced by a single instance of that letter.
| Sample Input 1 | Sample Output 1 |
|---|---|
bob | bob |
| Sample Input 2 | Sample Output 2 |
|---|---|
booob | bob |
| Sample Input 3 | Sample Output 3 |
|---|---|
boooooobapalaxxxxios | bobapalaxios |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
