Simply Scheme Project – Scoring Bridge Hands

Accidentally skipped over this project earlier and it was mentioned in the poker hands project so I am doubling back to do it. Full description at link. For this post I’m just quoting the descriptions of the subprocedures and tests.

Card-val

Write a procedure card-val that takes a single card as its argument and returns the value of that card.

My answer:

High-card-points

Write a procedure high-card-points that takes a hand as its argument and returns the total number of points from high cards in the hand. (This procedure does not count distribution points.)

My answer:

Count-suit

Write a procedure count-suit that takes a suit and a hand as arguments and returns the number of cards in the hand with the given suit.

My answer:

Suit-counts

Write a procedure suit-counts that takes a hand as its argument and returns a sentence containing the number of spades, the number of hearts, the number of clubs, and the number of diamonds in the hand.

My answer:

Suit-dist-points

Write suit-dist-points that takes a number as its argument, interpreting it as the number of cards in a suit. The procedure should return the number of distribution points your hand gets for having that number of cards in a particular suit.

My answer:

Hand-dist-points

Write hand-dist-points, which takes a hand as its argument and returns the number of distribution points the hand is worth.

My answer:

Bridge-val

Write a procedure bridge-val that takes a hand as its argument and returns the total number of points that the hand is worth.

My answer:

Full Program

Other People’s Solutions

I liked AnneB’s suit-counts: