Tommy is learning a simple card game called Circle. To play the game, the single player shuffles a deck of cards. He or she then flips through the deck, removing all instances of the 'K' card, and all consecutive pairs of cards that add up to 13. The deck does wrap around, so that if the last card remaining in the deck and the first card remaining in the deck add up to 13, they are both removed. The player keeps cycling through the deck until no more cards can be removed.
Create a class CircleGame containing the method cardsLeft that takes a String deck representing a not-necessarily complete nor correct deck of cards. Each character of deck represents the value of a card without the suit. The values shown on the card represent the following numerical values:
'A' - 1
'2' - 2
'3' - 3
'4' - 4
'5' - 5
'6' - 6
'7' - 7
'8' - 8
'9' - 9
'T' - 10
'J' - 11
'Q' - 12
'K' - 13
Given deck, return the number of cards remaining after the game has been played to its fullest such that no more cards can be removed. |