CPE 301 Programming Project

Clock Solitaire

Clock Solitaire is a simple card game.  The cards are dealt out (face down) in a circle, representing a clock, with a pile in each hour position and an extra pile in the center of the clock. The first card goes face down on one o'clock, the next on two, and so on clockwise from there, with each thirteenth card going to the center of the clock. This results in thirteen piles, with four cards face down in each pile.

clock solitaire layout

The game then starts. The top card of the 'king' pile (the last card dealt) is exposed to become the current card. Each move thereafter consists of placing the current card face up beneath the pile corresponding to its value and exposing the top card of that pile as the new current card. Thus if the current card is an Ace it is placed under the 'one' pile and the top card of that pile becomes the current card. The game ends when the pile indicated by the current card has no face down cards in it. You win if the entire deck is played out, i.e. exposed.  The outcome is entirely up to chance, there is no skill other than placing cards in the correct piles.

Play online version.

You are to write a computer player that simulates playing a Clock Solitaire game given a deck of shuffled cards, and return the results.

Input

The input data will be read from standard input and will contain one or more test cases.  Each test case contains a single line representing a shuffled deck of cards.  The first card is the top card on the deck.  The line consists of 52 2-letter card abbreviations, separated by one blank.  You may assume there are no duplicate cards, and all abbreviations are valid.

Output

For each test case, a single line of output is displayed on standard output.   The line contains two fields separated by a single blank.  The first field is a whole number representing the number of cards played during the game. The second field is a 2-letter card abbreviation of the last card played during the game.


Sample Input

2D 3C KC JS QC 5S KH 2H 3S 2C QH 8C TC QS 6D 5H TS 4H 7H 5D KD 4D AH 8S TH AC 4S 9C TD 3D 6C KS 4C 7C QD 3H 9S 7S AD AS JD 9H JC 8H 8D 7D 5C 6H 6S 9D 2S JH
9D 5D 9C KH QH 6H AH 3S AS 3H 8C 5S 9S 5C JC 9H 3D 7C 4D JD 8S KC JS TC 2S 6C TH TD 8H AD JH 5H 2C 4C TS 7D QD 8D 4S QC AC 2H 4H 6D 6S QS 3C KD KS 7S 2D 7H
2S AS 8H 3H TD 6S JH JC 4S 7D 5C 7C KS 2D AD 5S 4C QH 6H 9S 6C TS QD TH 7S KC 2C AC 3C 3S 9H QC 5H 4D 8C JS 8S 9D KH 2H AH QS 4H TC JD 3D 8D 7H 6D 9C 5D KD

Sample Output

52 KC
44 KC
4 KS

Implementation Constraints

The application class containing the main method should be named ClockSolitaire

Testing

Create a text file containing input data to be provided to the application. The input data should have at least one winning game and one losing game.

Test your application by running it at the command line using redirection.

Example unix command:
java ClockSolitaire < decks   will produce this output.


Submit printouts of your source code, sample input data and resulting output.