CIS 554 Clojure Poker
Fall 2014, David Matuszek

Purposes of this assignment

General idea of the assignment

Write and test code to evaluate a Poker hand.

You don't need to know Poker; you can think of this as an abstract exercise. While I believe this assignment is self-contained, you can visit the Wikipedia article on Poker hands for more information.


Poker cards have a rank (2, 3, 4, 5, 6, 7, 8, 9, 10, Jack=11, Queen=12, King=13, Ace=14) and a suit (Clubs, Diamonds, Hearts, Spades). A card will be represented by a two character string, the first indicating its rank (use T for 10), and the second indicating its suit. For example, "2C" would be the 2 of Clubs, and "JH" would be the Jack of Hearts. A deck of cards consists of 52 (4*13) cards, all different.

A hand consists of a vector of exactly five cards.

Write and test the following methods:

Useful built-in functions:

Unit tests

Here are some sample hands you can use for testing.

(def high-seven                   ["2H" "3S" "4C" "5C" "7D"])
(def pair-hand                    ["2H" "2S" "4C" "5C" "7D"])
(def two-pairs-hand               ["2H" "2S" "4C" "4D" "7D"])
(def three-of-a-kind-hand         ["2H" "2S" "2C" "4D" "7D"])
(def four-of-a-kind-hand          ["2H" "2S" "2C" "2D" "7D"])
(def straight-hand                ["2H" "3S" "6C" "5D" "4D"])
(def low-ace-straight-hand        ["2H" "3S" "4C" "5D" "AD"])
(def high-ace-straight-hand       ["TH" "AS" "QC" "KD" "JD"])
(def flush-hand                   ["2H" "4H" "5H" "9H" "7H"])
(def full-house-hand              ["2H" "5D" "2D" "2C" "5S"])
(def straight-flush-hand          ["2H" "3H" "6H" "5H" "4H"])
(def low-ace-straight-flush-hand  ["2D" "3D" "4D" "5D" "AD"])
(def high-ace-straight-flush-hand ["TS" "AS" "QS" "KS" "JS"])


Some of this assignment is "borrowed" from a very good online Clojure course. (Solutions are not provided! smiley)

Due date

Turn your assignment in to Canvas before 6am Friday, October 10. (This is to give you a chance to enjoy Fall break. However, expect a new assignment on Wednesday, October 8.)