Analysis of Java color tile programming problems
Niuniu likes colored things, especially colored tiles. Niuniu's room is paved with L square tiles. There are four possible colors for each brick: red, green, blue and yellow. Given a string s, if the ith character of S is' R ',' g ',' B 'or' y ', the color of the ith tile is red, green, blue or yellow respectively.
Niuniu decided to change the color of some tiles so that the colors of the two adjacent tiles are different. Please help Niu Niu calculate the minimum number of tiles he needs to replace.
Enter Description:
The input includes a line, a string s, string length (1 ≤ length ≤ 10), and each string in the string is' R ',' B 'or' y '.
Output Description:
Output an integer indicating the minimum number of tiles to be replaced
Example 1
input
RRRRRR
output
three