-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathColorfulTilesEasy.html
8 lines (8 loc) · 3.51 KB
/
ColorfulTilesEasy.html
1
2
3
4
5
6
7
8
<html><body bgcolor="#000000" text="#ffffff"><table><tr><td colspan="2"><h3>Problem Statement</h3></td></tr><tr><td>    </td><td>Taro likes <i>colorful</i> things, especially <i>colorful</i> tiles.
<br></br>
<br></br>
Taro's room is divided into L square tiles arranged in a row. Each tile is one of the following four colors: red, green, blue or yellow. You are given a string <b>room</b>. If the i-th character of <b>room</b> is 'R', 'G', 'B' or 'Y', the color of the i-th tile is red, green, blue or yellow, respectively.
<br></br>
<br></br>
He decided to change the color of some tiles so that no two adjacent tiles have the same color. Return the minimal number of tiles he must change.</td></tr><tr><td colspan="2"><h3>Definition</h3></td></tr><tr><td>    </td><td><table><tr><td>Class:</td><td>ColorfulTilesEasy</td></tr><tr><td>Method:</td><td>theMin</td></tr><tr><td>Parameters:</td><td>string</td></tr><tr><td>Returns:</td><td>int</td></tr><tr><td>Method signature:</td><td>int theMin(string room)</td></tr><tr><td colspan="2">(be sure your method is public)</td></tr></table></td></tr><tr><td>    </td></tr><tr><td></td></tr><tr><td colspan="2"><h3>Constraints</h3></td></tr><tr><td align="center" valign="top">-</td><td><b>room</b> will contain between 1 and 10 characters, inclusive.</td></tr><tr><td align="center" valign="top">-</td><td>Each character in <b>room</b> will be 'R', 'G', 'B' or 'Y'.</td></tr><tr><td colspan="2"><h3>Examples</h3></td></tr><tr><td align="center" nowrap="true">0)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>"RRRRRR"</pre></td></tr></table></td></tr><tr><td><pre>Returns: 3</pre></td></tr><tr><td><table><tr><td colspan="2">For example, he can change three tiles in the following way:
"RRRRRR" -> "RGRGRG".</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">1)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>"GGGGGGG"</pre></td></tr></table></td></tr><tr><td><pre>Returns: 3</pre></td></tr><tr><td><table><tr><td colspan="2">For example, "GGGGGGG" -> "GRGRGRG".</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">2)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>"BBBYYYYYY"</pre></td></tr></table></td></tr><tr><td><pre>Returns: 4</pre></td></tr><tr><td><table><tr><td colspan="2">For example, "BBBYYYYYY" -> "BRBYRYRYR".</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">3)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>"BRYGYBGRYR"</pre></td></tr></table></td></tr><tr><td><pre>Returns: 0</pre></td></tr><tr><td><table><tr><td colspan="2">The condition is already satisfied, so he doesn't need to change any tiles.</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">4)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>"RGGBBBRYYB"</pre></td></tr></table></td></tr><tr><td><pre>Returns: 3</pre></td></tr><tr><td><table><tr><td colspan="2"></td></tr></table></td></tr></table></td></tr></table><p>This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved. </p></body></html>