- Problem Statement.
- A
**main()**with the examples compiled in. - A skeleton that compiles with
**main.cpp**. -
**Problem Given in Topcoder**: December, 2014 -
**Competitors who opened the problem**: 761 -
**Competitors who submitted a solution**: 684 -
**Number of correct solutions**: 451 -
**Accuracy (percentage correct vs those who opened)**: 59.26% -
**Average Correct Time**: 15 minutes, 21 seconds.

From the example in the writeup, if there are two adjacent H's, either horizonally or vertically, then the whole army will eventually be happy. So, the King's goal is to make sure that there are two adjacent happy soldiers. This means that there are only three cases to care about:

- If there are two adjacent H's, return 0.
- Otherwise, if there is an H anywhere, return 1, because the king can simply place an H adjacent to one that's already there.
- If there are no H's, then return 2, because the king needs to place two H's next to each other.

- Look to make sure that at least one string has an H. If not, return 2. I used a
**for**loop and the**find()**method of strings to do this part. - Now, look to see if there is an "HH" in any string. Again, you can use a
**for**loop and the**find()**method of strings. If you find an "HH", then return 0. - Look for two H's that are adjacent vertically. This requires a double
**for**loop. If you find two H's that are adjacent vertically, return 0. - If you've reached this point, then there is at least one H, but no adjacent H's. Return 1.