Skip to content

Commit 318bef0

Browse files
committed
Add q77
1 parent 092ecc2 commit 318bef0

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/ex/q077.clj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
;; https://4clojure.oxal.org/#/problem/077
2+
3+
(ns ex.q077)
4+
5+
(defn ans
6+
"Problem 77, Anagram Finder"
7+
[coll]
8+
(letfn [(hash-word [w] (->> w sort (apply str) hash))]
9+
(set
10+
(filter #(> (count %) 1)
11+
(map set (vals (group-by hash-word coll)))))))

test/ex/q077_test.clj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
;; https://4clojure.oxal.org/#/problem/077
2+
3+
(ns ex.q077-test
4+
(:require [clojure.test :as t]
5+
[ex.q077 :as sut]))
6+
7+
(t/deftest test-q77
8+
(t/testing "Problem 77, Anagram Finder"
9+
(t/is (= #{#{"meat" "team" "mate"}}
10+
(sut/ans ["meat" "mat" "team" "mate" "eat"])))
11+
(t/is (= #{#{"veer" "ever"} #{"lake" "kale"} #{"mite" "item"}}
12+
(sut/ans ["veer" "lake" "item" "kale" "mite" "ever"])))))

0 commit comments

Comments
 (0)