diff --git a/src/ex/q077.clj b/src/ex/q077.clj new file mode 100644 index 0000000..c297456 --- /dev/null +++ b/src/ex/q077.clj @@ -0,0 +1,11 @@ +;; https://4clojure.oxal.org/#/problem/077 + +(ns ex.q077) + +(defn ans + "Problem 77, Anagram Finder" + [coll] + (letfn [(hash-word [w] (->> w sort (apply str) hash))] + (set + (filter #(> (count %) 1) + (map set (vals (group-by hash-word coll))))))) \ No newline at end of file diff --git a/test/ex/q077_test.clj b/test/ex/q077_test.clj new file mode 100644 index 0000000..2e4e4ac --- /dev/null +++ b/test/ex/q077_test.clj @@ -0,0 +1,12 @@ +;; https://4clojure.oxal.org/#/problem/077 + +(ns ex.q077-test + (:require [clojure.test :as t] + [ex.q077 :as sut])) + +(t/deftest test-q77 + (t/testing "Problem 77, Anagram Finder" + (t/is (= #{#{"meat" "team" "mate"}} + (sut/ans ["meat" "mat" "team" "mate" "eat"]))) + (t/is (= #{#{"veer" "ever"} #{"lake" "kale"} #{"mite" "item"}} + (sut/ans ["veer" "lake" "item" "kale" "mite" "ever"]))))) \ No newline at end of file