PROBLEM STATEMENT
You are an expert card dealer capable of executing a perfect riffle shuffle. A
perfect riffle shuffle is one in which a deck of 52 playing cards (numbered
from 1 to 52 starting from the bottom) is first divided in half. The bottom
half contains cards numbered from 1 to 26 and the top half contains cards
numbered from 27 to 52. The result of a perfect riffle shuffle is that the two
halves of the deck are interleaved so that the resulting shuffled deck is
ordered such that either
1. the bottom most card is from the bottom half:
1,27,2,28,3,29,...,25,51,26,52
or
2. the bottom most card is from the top half:
27,1,28,2,29,3,...,51,25,52,26
with respect to the numbering of the cards before the shuffle.
You would like to calculate the minimum number of consecutive perfect riffle
shuffles needed to move a card from one given position to another given
position. If there is no sequence of perfect shuffles to move a card from
start to finish, you should return -1.
DEFINITION
Class: Dealer
Method: shuffles
Parameters: int,int
Returns: int
Here is the method signature (be sure your method is public): int shuffles(int
startPosition, int finishPosition);
NOTES
Topcoder will ensure that:
* 1 <= startPosition <= 52
* 1 <= finishPosition <= 52
EXAMPLES
1. startPosition = 1
finishPosition = 2
Method returns 1
2. startPositon = 2
finishPosition = 1
Method returns 5
3. startPosition = 1
finishPosition = 52
Method returns 6
4. startPosition = 52
finishPosition = 1
Method returns 6
5. startPosition = 7
finishPosition = 7
Method returns 0