Last active
August 29, 2015 14:00
-
-
Save hadronzoo/11305756 to your computer and use it in GitHub Desktop.
Attempt 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn minmax-by-codepoint [s] | |
(let [sorted (reduce (fn [r [c cnt]] | |
(update-in r [cnt] #((fnil conj (sorted-set)) % c))) | |
(sorted-map) | |
(frequencies s)) | |
get-char (juxt (comp first second) first)] | |
[(get-char (first sorted)) | |
(get-char (last sorted))])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment