|
|||
Hop — Don't Walk!KERMIT THE FROG is a classic video game with a simple control and objective but requires a good deal of thinking. You control an animated frog that can walk and hop, in both forward and backward directions. The frog stands in a space between an otherwise contiguous line of tiles. Each tile is painted black on one side, and white on the other. The frog can walk (forward or backward) over an adjacent tile (in front or behind him). When the frog walks over a tile, the tile slides to the space where the frog was standing.
For example, in the figure above, the frog has two tiles behind him, and three in front.
We'll use the notation Input Specification
Your program will be tested on one or more test cases. Each test case is specified on a
single line that specifies string S representing the initial tile arrangement.
S is a non-empty string and no longer than 100 characters and is made up of the
letters “ Output SpecificationFor each test case, print the following line: k. M
Where k is the test case number (starting at one), and M is the minimum number of moves needed to transform the given arrangement to an arrangement that has no white tiles between any of its black tiles. The frog can be anywhere. M should be −1 if the problem cannot be solved in less than 10 moves. Sample Input
Output for Sample Input
|
|||
University of Debrecen; Faculty of Informatics; v. 03/01/2019 |