Skip to content

Instantly share code, notes, and snippets.

@craig-ludington
Created July 12, 2016 22:36
Show Gist options
  • Save craig-ludington/326e26b1e57a5f1d2cc4bc93e07d33db to your computer and use it in GitHub Desktop.
Save craig-ludington/326e26b1e57a5f1d2cc4bc93e07d33db 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