Statistics

Problem Statement for "Big2"

Problem Statement

PROBLEM STATEMENT

Big Two is a Chinese card game in which players take turns placing cards - the
person running out of cards first winning the game.  Big Two is played with a
standard 52-card deck and four players.  Each player is dealt 13 cards.  A
standard deck of cards consists of four each of {A,2,3,4,5,6,7,8,9,T,J,Q,K},
one of each suit {clubs, diamonds, hearts, spades}, for a total of 52 cards.
One possible play in Big Two is the "poker-hand".  Given a set of 13 cards,
determine the number of different poker-hands that could possibly be played
with those cards.

The ordering of the cards is:
'A','2','3','4','5','6','7','8','9','T','J','Q','K','A'.  Note that the 'A' can
either be the high card or the low card.

The following are the allowed poker-hands in Big Two:

straight --- five consecutive cards, where the A could be either before the 2
or after the K.  Straights cannot wrap around.  For example, {A, 2, 3, 4, 5}
and {T, J, Q, K, A} are both straights, but {Q, K, A, 2, 3} is not.

flush --- five cards of the same suit.  For example, {2 of clubs, 4 of clubs, 6
of clubs, 7 of clubs, J of clubs} is a flush.

full house -- one pair and one three of a kind.  For example, {3, 3, J, 3, J}
is a full house.

four of a kind --- a four of a kind and a fifth card.  For example, {7, K, 7,
7, 7} is a four of a kind.

straight flush --- five cards satisfying the requirements for both a straight
and a flush.


DEFINITION
Class: Big2
Method: pokerHands
Parameters: String[]
Returns: int
Method signature (be sure your method is public):  int pokerHands(String[]
cards);


NOTES
- each distinct set of five cards can be considered at most one poker hand.
Thus, if you have a straight flush, do not count it three times (straight,
flush, and straight flush).
- it is impossible to be dealt 2 of the exact same card (same value and suit).


TopCoder will ensure the validity of the inputs.  Inputs are valid if all of
the following criteria are met:
- cards will contain exactly 13 elements.
- each element of cards will be of the form "XY" where X is one of the
characters 'A', '2'-'9' inclusive, 'T', 'J', 'Q', and 'K', representing the
value of the card, and Y is one of the characters 's', 'h', 'd', and 'c',
representing the suit of the card (spades, hearts, diamonds, and clubs,
respectively).  Note that the characters representing the values of the cards
must be uppercase, and the characters representing the suits of the cards must
be lowercase.
- each element of cards has length 2.
- no two elements of cards will be identical.


EXAMPLES
1) cards = {"2c","2d","2h","2s","3c","5c","6c","8c","8d","9d","Jh","Qc","Qh"}

four of a kinds: 9 (choose all four 2's and another card).
full houses: 8 (choose three of the four 2's and either the pair of 8's or Q's).
flushes: 6 (choose 5 of the 6 clubs).
straights: none.

returns: 23


2) cards = {"2c","2d","4c","4d","6c","6d","8c","8d","Ts","Th","Js","Qh","Ah"}

This contains zero poker hands.  returns: 0


3) cards = {"2c","2d","4c","4d","6c","6d","8c","8d","Ts","Th","Js","Qh","2h"}

returns: 4


4) cards = {"6c","7h","3d","3h","Th","Qh","As","Kh","Jd","Jh","4d","3c","Ah"}

returns: 26


5) cards = {"3s","7h","3d","3h","Th","Qh","As","Kh","Jd","Jh","4d","3c","Ah"}

returns: 41

Definition

Class:
Big2
Method:
pokerHands
Parameters:
String[]
Returns:
int
Method signature:
int pokerHands(String[] param0)
(be sure your method is public)

Constraints

    Examples


      This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
      This problem was used for: