Skip to content

Instantly share code, notes, and snippets.

@briansunter
Created April 6, 2017 01:26
Show Gist options
  • Save briansunter/799e5624776d00d78b2257c3185874d5 to your computer and use it in GitHub Desktop.
Save briansunter/799e5624776d00d78b2257c3185874d5 to your computer and use it in GitHub Desktop.
Hacker Rank: Making Anagrams
;; 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