Stones in a Row (Strings)

A row of stones is written as a string of R, G and B. Print the fewest stones to take away so that no two neighbouring stones have the same colour.

Input: One string of R, G and B, length 1 to 50.

Output: One integer.

Difficulty: Easy. Write your answer in the browser editor, run the examples, then submit it against hidden tests. Python and JavaScript are free; other languages are part of licode Club.

Hint

  • Compare every stone with the one just before it.

More Strings practice