Created
July 10, 2014 14:48
-
-
Save rockBreaker/5f8e2efb060f68756dc0 to your computer and use it in GitHub Desktop.
horrible code mrk2 needs formatting, checks for a straight, inc low ace case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn straight? [hand] | |
(let [sorted-hand | |
(fn[hand] (sort (keys (frequencies (map rank hand))))) | |
range-helper | |
(fn [hand] (= hand (range (apply min hand) (inc (apply max hand))))) | |
low-ace | |
(fn [hand] (range-helper (sort (replace {14 1} (sorted-hand hand)))))] | |
(and | |
(= (count (sorted-hand hand)) 5) | |
(or | |
(range-helper (sorted-hand hand)) | |
(low-ace hand ))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment