Skip to content

Instantly share code, notes, and snippets.

@rockBreaker
Created July 10, 2014 14:34
Show Gist options
  • Save rockBreaker/8f58effcae101d252d85 to your computer and use it in GitHub Desktop.
Save rockBreaker/8f58effcae101d252d85 to your computer and use it in GitHub Desktop.
horrible clojure code to sort a poker hand and check for a straight
;sorted hand vals
(defn sorted-hand-vals [hand]
(sort (keys (frequencies (map rank hand)))))
(defn low-ace-helper [hand]
(= hand (range (apply min hand) (inc (apply max hand)))))
;low ace straight?
(defn low-ace-straight? [hand]
(low-ace-helper (sort (replace {14 1} (sorted-hand-vals hand)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment