Skip to content

Instantly share code, notes, and snippets.

@deanrad
Forked from craig-ludington/words.clj
Created July 13, 2016 14:14
Show Gist options
  • Save deanrad/82ba4bb148c25917b51f9d30e93504e5 to your computer and use it in GitHub Desktop.
Save deanrad/82ba4bb148c25917b51f9d30e93504e5 to your computer and use it in GitHub Desktop.
(defn score
[word]
(let [wc (count word)
uc (count (into #{} (map identity (clojure.string/lower-case word))))]
{:word word :score (if (= wc uc) wc 0)}))
(defn winner
[words]
(let [m (group-by :score (map score words))]
(m (apply max (keys m)))))
;; (winner (clojure.string/split-lines (slurp "/usr/share/dict/web2")))
;; => [{:word "dermatoglyphics", :score 15}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment