Contract Bridge is a card game where players must bid how many tricks they will win at the start of the play. To do this, players evaluate their hands and assign a point value to the hand.
For this assignment you will read in a representation of a bridge hand, evaluate the point value, and print out how many points are in the hand.
A bridge hand is made up of 13 cards. Each card has a face value, represented as one of the character sequences A,2,3,4,5,6,7,8,9,10,J,Q,K; and a suit, represented by one of the characters C D H S. So, for example, the nine of clubs is represented as 9C.
The input to the program will be strings representing cards. Each card is a face value separated from the other by a comma, spaces or newlines. When the input contains a single line containing nothing but a dot character, this indicates that the input of this hand is complete.
Once you read a hand in, you must apply following rules to calculate the point value for hand:
When you calculate the resulting points, you should print out, on a line by itself: HAND x TOTAL POINTS y
Where x is an integer indicating the hand that was read in (the first hand is 1, the second is 2, etc.), and y is the points that you calculated for the hand.
Your program will read the standard input for a hand. When the input of the hand is complete, your program should validate that the hand is correct, calculate the points, print the result, and read the standard input for the next hand.
A hand is correct if and only if it has 13 correctly formatted unique cards in it. If any of the cards is incorrectly formatted, the program should print BAD FORMAT. If the count of cards is wrong, the program should print WRONG NUMBER OF CARDS. If there are duplicate cards in the hand, the program should print DUPLICATE CARDS. In these error cases, the program should continue reading the standard input for the next hand after it prints the error message.
Your program should terminate on end-of-file.