Created
April 6, 2017 01:26
-
-
Save briansunter/799e5624776d00d78b2257c3185874d5 to your computer and use it in GitHub Desktop.
Hacker Rank: Making Anagrams
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
;; https://www.hackerrank.com/challenges/ctci-making-anagrams | |
(defn char-frequencies | |
[x] | |
(reduce #(update %1 %2 (fnil inc 0)) {} x)) | |
(let [a (read-line) | |
b (read-line) | |
a-freq (char-frequencies a) | |
b-freq (char-frequencies b) | |
diff (merge-with - a-freq b-freq)] | |
(println (reduce + (map Math/abs (vals diff))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment