Skip to content

Commit 2d566c2

Browse files
committed
Add q81
1 parent d696095 commit 2d566c2

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/ex/q081.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/081
2+
3+
(ns ex.q081)
4+
5+
(defn ans
6+
"Problem 81, Set Intersection"
7+
[a b]
8+
(let [union (apply conj a b)]
9+
(->> union
10+
(filter #(and (contains? a %) (contains? b %)))
11+
set)))

test/ex/q081_test.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/081
2+
3+
(ns ex.q081-test
4+
(:require [clojure.test :as t]
5+
[ex.q081 :as sut]))
6+
7+
(t/deftest test-q81
8+
(t/testing "Problem 81, Set Intersection"
9+
(t/is (= #{2 3} (sut/ans #{0 1 2 3} #{2 3 4 5})))
10+
(t/is (= #{} (sut/ans #{0 1 2} #{3 4 5})))
11+
(t/is (= #{:a :c :d} (sut/ans #{:a :b :c :d} #{:c :e :a :f :d})))))

0 commit comments

Comments
 (0)