ECOO TRYOUTS 1999

Bridge Hand Evaluator

INPUT FILE: bridge.in
OUTPUT FILE: bridge.out

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:

  1. Each ace counts four points. Each king counts three points. Each queen counts two points. Each jack counts one point.
  2. Subtract a point for any king in a suit in which the hand holds no other cards.
  3. Subtract a point for any queen in a suit in which the hand holds only one other card or less.
  4. Subtract a point for any jack in a suit in which the hand holds only two other cards or less.
  5. Add a point for each suit in which the hand contains exactly two cards.
  6. Add two points for each suit in which the hand contains exactly one card.
  7. Add two points for each suit in which the hand contains no cards.

A suit is stopped if it contains an ace, or a king and one or more other cards, or a queen and two or more other cards.

During the opening assessment, the three most common possibilities are:

INPUT
On each line there will be 13 cards, separated by a space each. Each card contains two characters: first one of A, 2, 3, 4, 5, 6, 7, 8, 9, J, Q, K for the rank of the card and then one of C, D, H, S for clubs, diamonds, hearts or spades respectively.

OUTPUT
For each line of input, output the recommended bid: either "PASS", "BID suit" where suit is one of C, D, H, S or "BID NO-TRUMP". If more than one bid is possible, you should give preference to the highest bid. No-trump is highest followed by spades, hearts, diamonds and finally clubs.

Sample Input File

KS QS TH 8H 4H AC QC TC 5C KD QD JD 8D

For this hand, the evaluation starts out 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 one point having only two cards in spades, and subtract one point for having a queen in spades with only one other spade card. The resulting 17 cards 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. Since diamonds are higher than clubs our bid will be "BID D".

Output for Sample Input

BID D
Downloader failed! Response object 006~ASP 0159~Buffering Off~Buffering must be on.