Bridge Hands |
Many games, such as Bridge, involve dealing a standard deck of 52 cards to 4 players, so each receives 13 cards. Good players can then play with the hand as it is dealt, but most ordinary players will need to sort it, firstly by suit, and then by rank within suit.
There is no fixed ranking of the suits for this purpose, but it is useful to
alternate the colours, so we
will presume the following ordering: CLUBS < DIAMONDS < SPADES < HEARTS.
(Note that
from now on we will use the more conventional C, D, S, H). Within a suit Ace is high, so the
ordering is 2 < 3 < 4 < 5 < 6 < 7 < 8 < 9 < T < J < Q < K < A.
The players are usually designated North, South, East and West, and they sit
at the points of the
compass they name. One player is designated the dealer and he (or she) deals
one card to each
player starting with the player on his (her) left hand and proceeding
clockwise until he (she) deals the last card to himself (herself).
Write a program that will read in a presentation of a deck of cards, deal them, sort them, and then display the 4 sorted hands in the format shown below.
N CQDTC4D8S7HTDAH7D2S3D6C6S6D9S4SAD7H2CKH5D3CTS8C9H3C3 DQS9SQDJH8HAS2SKD4H4S5C7SJC8DKC5C2CAHQCJSTH6HKH9D5HJ #
S: C3 C5 C7 CT CJ D9 DT DJ S3 SK H2 H9 HT W: C2 C4 CK D4 D5 D6 DQ DA S4 S8 ST SJ H8 N: C6 C8 C9 CA D8 S9 SA H4 H5 H6 H7 HJ HA E: CQ D2 D3 D7 DK S2 S5 S6 S7 SQ H3 HQ HK