American Computer Science League: 2008/09 Contest #2
ACSL Pinochle (Senior)
Pinochle uses a deck of 48 cards that is dealt out to the players (16 cards each).
A deck has 2 of each type of card (Ace, King, Queen, Jack, 10, 9) per suit (diamonds, clubs, spades, hearts).
The first step in playing the game is to count the number of points in a hand using the following rules:
|#1||Single Book - A,K,Q,J,T in trump suit||15||#8||Trump Marriage - 1 K & 1 Q in trump suit||4|
|#2||Double Book - 2x each A,K,Q,J,T in trump suit||150||#9||Marriage - 1 K & 1 Q in non-trump suit||2|
|#3||2 Jacks of Diamonds &|
2 Queens of Spades
|30||#10||1 Jack of Diamonds &|
1 Queen of Spades
|#4||4 Aces (1 in each suit)||10||#11||4 Queens (1 in each suit)||6|
|#5||4 Kings (1 in each suit)||8||#12||4 Jacks (1 in each suit)||4|
|#6||8 Aces (2 in each suit)||100||#13||8 Queens (2 in each suit)||60|
|#7||8 Kings (2 in each suit)||80||#14||8 Jacks (2 in each suit)||40|
The same card can be used in multiple cases but only once in each case. If a hand has two Jacks of diamonds and two Queens of spades, those cards could be used in Case #3 and Case #10 to accumulate 38 points.
The only exception to the above rule is the King and Queen that are in the single book (Case #1). They may not be the King & Queen in the trump marriage (Case #8). The only way to have a single book and a trump marriage in the same hand is to have the Ace, King, Queen, Jack and 10 for the book, while also having another King and another Queen in trump to earn the 19 points. In general, one can have multiple marriages within the same suit during the same hand - each getting the appropriate points.
InputThere will be 5 cases each representing the cards in one hand. Each case will consist of 5 lines. The first string will be one-character in length and will give the trump suit (D, C, S or H). The other 4 strings name the cards in each suit of the hand. The order will always be diamonds, clubs, spades and then hearts. The card names used will be A (Ace), K (King), Q (Queen), J (Jack), T (Ten) and N (Nine). There will always be at least one card in each suit.
OutputThe score for each input hand.
D ATKQQJ AKQQ KQQJN A C KQN ATTQN AQJ ATKQJ S ATKQJN TKJ ATKQJ JN H AKN ATKJN QN ATQQJN
23 10 25 0
Point Value: 10 (partial)
Time Limit: 2.00s
Memory Limit: 16M
C++, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3