Skip to content

Instantly share code, notes, and snippets.

@amalloy
Created September 3, 2013 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amalloy/e3368747b399e83b91d6 to your computer and use it in GitHub Desktop.
Save amalloy/e3368747b399e83b91d6 to your computer and use it in GitHub Desktop.
(defn selections [choices]
(if (empty? choices)
'(())
(let [more (selections (rest choices))]
(for [choice (first choices)
answer more]
(cons choice answer)))))
(defn score-card [[rank suit]]
(cond (number? rank) [rank]
(= :ace rank) [1 11]
:else [10]))
(defn score-hand [cards]
(map (partial apply +)
(selections (map score-card cards))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment