|
2 | 2 | (:use midje.sweet
|
3 | 3 | p-p-p-pokerface))
|
4 | 4 |
|
5 |
| -(facts "rank" |
| 5 | +(facts "1 suit" |
| 6 | + (suit "2H") => "H" |
| 7 | + (suit "2D") => "D" |
| 8 | + (suit "2C") => "C" |
| 9 | + (suit "3S") => "S") |
| 10 | + |
| 11 | +(facts "2 rank" |
6 | 12 | (rank "2H") => 2
|
7 | 13 | (rank "4S") => 4
|
8 | 14 | (rank "TS") => 10
|
|
11 | 17 | (rank "KS") => 13
|
12 | 18 | (rank "AS") => 14)
|
13 | 19 |
|
14 |
| -(facts "suit" |
15 |
| - (suit "2H") => "H" |
16 |
| - (suit "2D") => "D" |
17 |
| - (suit "2C") => "C" |
18 |
| - (suit "3S") => "S") |
19 |
| - |
20 | 20 | (def high-seven ["2H" "3S" "4C" "5C" "7D"])
|
21 | 21 |
|
22 | 22 | (def pair-hands #{["2H" "2S" "4C" "5C" "7D"]
|
|
38 | 38 | (def low-ace-straight-flush-hand ["2D" "3D" "4D" "5D" "AD"])
|
39 | 39 | (def high-ace-straight-flush-hand ["TS" "AS" "QS" "KS" "JS"])
|
40 | 40 |
|
41 |
| -(facts "pair" |
| 41 | +(facts "3 pair?" |
42 | 42 | (every? pair? pair-hands) => true
|
43 | 43 | (pair? high-seven) => false)
|
44 | 44 |
|
45 |
| -(facts "two-pairs?" |
46 |
| - (two-pairs? two-pairs-hand) => true |
47 |
| - (two-pairs? three-of-a-kind-hand) => false |
48 |
| - (two-pairs? pair-hand) => false) |
49 |
| - |
50 |
| -(facts "three-of-a-kind?" |
| 45 | +(facts "4 three-of-a-kind?" |
51 | 46 | (three-of-a-kind? two-pairs-hand) => false
|
52 | 47 | (three-of-a-kind? three-of-a-kind-hand) => true)
|
53 | 48 |
|
54 |
| -(facts "four-of-a-kind?" |
| 49 | +(facts "5 four-of-a-kind?" |
55 | 50 | (four-of-a-kind? two-pairs-hand) => false
|
56 | 51 | (four-of-a-kind? four-of-a-kind-hand) => true)
|
57 | 52 |
|
| 53 | +(facts "6 flush?" |
| 54 | + (flush? pair-hand) => false |
| 55 | + (flush? flush-hand) => true) |
| 56 | + |
| 57 | +(facts "7 full-house?" |
| 58 | + (full-house? three-of-a-kind-hand) => false |
| 59 | + (full-house? four-of-a-kind-hand) => false |
| 60 | + (full-house? full-house-hand) => true) |
| 61 | + |
| 62 | +(facts "8 two-pairs?" |
| 63 | + (two-pairs? two-pairs-hand) => true |
| 64 | + (two-pairs? three-of-a-kind-hand) => false |
| 65 | + (two-pairs? pair-hand) => false) |
| 66 | + |
58 | 67 | (tabular
|
59 |
| - (facts "straight?" |
| 68 | + (facts "9 straight?" |
60 | 69 | (straight? ?hand) => ?result)
|
61 | 70 | ?hand ?result
|
62 | 71 | two-pairs-hand false
|
|
66 | 75 | ["2H" "3H" "3D" "4H" "6H"] false
|
67 | 76 | high-ace-straight-hand true)
|
68 | 77 |
|
69 |
| -(facts "flush?" |
70 |
| - (flush? pair-hand) => false |
71 |
| - (flush? flush-hand) => true) |
72 |
| - |
73 |
| -(facts "full-house?" |
74 |
| - (full-house? three-of-a-kind-hand) => false |
75 |
| - (full-house? four-of-a-kind-hand) => false |
76 |
| - (full-house? full-house-hand) => true) |
77 |
| - |
78 |
| -(facts "straight-flush?" |
| 78 | +(facts "10 straight-flush?" |
79 | 79 | (straight-flush? straight-hand) => false
|
80 | 80 | (straight-flush? flush-hand) => false
|
81 | 81 | (straight-flush? straight-flush-hand) => true
|
82 | 82 | (straight-flush? low-ace-straight-flush-hand) => true
|
83 | 83 | (straight-flush? high-ace-straight-flush-hand) => true)
|
84 | 84 |
|
85 |
| -(facts "value" |
| 85 | +(facts "11 value" |
86 | 86 | (value high-seven) => 0
|
87 | 87 | (every? (partial = 1) (map value pair-hands)) => 1
|
88 | 88 | (value two-pairs-hand) => 2
|
|
0 commit comments