Skip to content

Instantly share code, notes, and snippets.

@rockBreaker
Created July 10, 2014 14:48
Show Gist options
  • Save rockBreaker/5f8e2efb060f68756dc0 to your computer and use it in GitHub Desktop.
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
(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