your program name must be: prob11.exe
programmers: your program name must be: prob11.class
The poker game, Texas Hold‘Em, has
exploded in popularity in recent years—so much so that
you can even find poker tables at your local grocery
store. The rules of Hold‘Em are pretty simple. Each
player is dealt two cards facedown. Next three
community cards (cards that everyone can play) are dealt
face up in the middle of the table—this is called the
flop. Next, a fourth community card, called the turn,
is dealt. And finally, the fifth community card, or the
river is dealt. The winner is the player that can make
the best poker hand out of any combination of his or her
two hole cards and the five community cards.
For Hold‘Em players, many a fortune
has been won and lost on the river card. The river can
turn a big winning hand into an equally large losing
hand in an instant. Therefore, in Code Wars Hold ‘Em
we’ve decided to eliminate the river all
together—leaving just four community cards from which to
make your poker hand. Since we are getting rid of the
river, we’ll also only allow you to use four cards to
make up your poker hand.
Your task is to write a program to
determine the winner of a CodeWars Hold’Em game between
A poker deck contains 52 cards - each
card has a suit which is one of clubs, diamonds, hearts,
or spades (denoted C, D, H, and S in the input data).
Each card also has a value which is one of 2, 3, 4, 5,
6, 7, 8, 9, 10, jack, queen, king, ace (denoted 2, 3, 4,
5, 6, 7, 8, 9, T, J, Q, K, A). For scoring purposes, the
suits are unordered while the values are ordered as
given above, with 2 being the lowest and ace the highest
A Code Wars Hold’Em hand consists of
4 cards from the deck. Hands are ranked by the following
partial order from lowest to highest:
Hands which do not fit any higher category are
ranked by the value of their highest card. If the
highest cards have the same value, the hands are
ranked by the next highest, and so on.
2 of the 4 cards in the hand have the same value.
Hands which both contain a pair are ranked by the
value of the cards forming the pair. If these values
are the same, the hands are ranked by the values of
the cards not forming the pair, in decreasing order.
Hand contains 4 cards of the same suit. Hands which
are both flushes are ranked using the rules for High
The hand contains 2 different pairs. Hands which
both contain 2 pairs are ranked by the value of
their highest pair. Hands with the same highest pair
are ranked by the value of their other pair. If
these values are the same the hands are ranked by
the value of the remaining card.
Hand contains 4 cards with consecutive values. Hands
which both contain a straight are ranked by their
Three of a Kind:
Three of the cards in the hand have the same value.
Hands which both contain three of a kind are ranked
by the value of the 3 cards.
4 cards of the same suit with consecutive values.
Ranked by the highest card in the hand.
Four of a kind:
4 cards with the same value. Ranked by the value of
the 4 cards.
The input file (prob11.in) contains 4
line of two cards denoted each of the players hole
cards. A fifth line will represent the four community
cards. Each card is depicted as two numbers or letters
denoting its rank and suit in that order. A space will
separate each card.
2H TC JH 4H
Output to the screen the winning
player and a description of the winning hand:
Player 2-Three of a