We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d696095 commit 2d566c2Copy full SHA for 2d566c2
src/ex/q081.clj
@@ -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
+(ns ex.q081-test
+ (:require [clojure.test :as t]
+ [ex.q081 :as sut]))
+(t/deftest test-q81
+ (t/testing "Problem 81, Set Intersection"
+ (t/is (= #{2 3} (sut/ans #{0 1 2 3} #{2 3 4 5})))
+ (t/is (= #{} (sut/ans #{0 1 2} #{3 4 5})))
+ (t/is (= #{:a :c :d} (sut/ans #{:a :b :c :d} #{:c :e :a :f :d})))))
0 commit comments