Bridge Hand Evaluator |
In the card game ``Bridge'', players must assess the strength of their hands prior to bidding against one another. Most players use a point-count scheme which employs the following rules:
A suit is stopped if it contains an ace, or if it contains a king and at least one other card, or if it contains a queen and at least two other cards.
During the opening assessment, the three most common possibilities are:
Standard input gets 13 cards on one line. Each card consists of two characters. The first represents the rank of the card: `A', `2', `3', `4', `5', `6', `7', `8', `9', `T', `J', `Q', `K'. The second represents the suit of the card: `S', `H', `D', `C', standing for ``spades'', ``hearts'', ``diamonds'', and ``clubs'', respectively.
The recommended bid, either ``PASS'', the first ``BID suit'', where suit is ``S'', ``H'', ``D'', or ``C'' (sorted in this natural way if two or more are possible), or ``BID NO-TRUMP''.
For the example below, the evaluation starts with 6 points for the two kings, 4 for the ace, 6 for the three queens, and one for the jack. To this tally of 17 points, we add 1 point for having only two cards in spades, and subtract 1 for having a queen in spaces with only one other card in spades. The resulting 17 points is enough to justify opening in a suit.
The evaluation for no-trump is 16 points, since we cannot count the one point for having only two spades. We cannot open in no-trump, however, because the hearts suit is not stopped.
Hence we must open bidding in a suit. The two longest suits are clubs and diamonds, with four cards each, so the possible outputs are ``BID C'', or ``BID D''.
KS QS TH 8H 4H AC QC TC 5C KD QD JD 8D
BID D