Skip to content

Instantly share code, notes, and snippets.

@hadronzoo
Last active August 29, 2015 14:00
Show Gist options
  • Save hadronzoo/11305756 to your computer and use it in GitHub Desktop.
Save hadronzoo/11305756 to your computer and use it in GitHub Desktop.
Attempt 2
(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