From d42a687d3de8c12c97de7855c13ef70f4bf22778 Mon Sep 17 00:00:00 2001 From: David Kun Date: Thu, 5 Sep 2024 21:12:59 -0400 Subject: [PATCH] Add q65 --- src/ex/q065.clj | 15 +++++++++++++++ test/ex/q065_test.clj | 12 ++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 src/ex/q065.clj create mode 100644 test/ex/q065_test.clj diff --git a/src/ex/q065.clj b/src/ex/q065.clj new file mode 100644 index 0000000..3878900 --- /dev/null +++ b/src/ex/q065.clj @@ -0,0 +1,15 @@ +;; https://4clojure.oxal.org/#/problem/065 + +(ns ex.q065) + +(defn ans + "Problem 65, Black Box Testing" + [coll] + (println coll) + (println (conj coll [:david :kun] [:david :kun])) + (cond + (= :kun (:david (conj coll [:david :kun]))) :map + (= (inc (count coll)) (count (conj coll [:david :kun] [:david :kun]))) :set + (= :kun (first (conj coll :david :kun))) :list + (= :kun (last (conj coll :david :kun))) :vector + :else :unknown)) \ No newline at end of file diff --git a/test/ex/q065_test.clj b/test/ex/q065_test.clj new file mode 100644 index 0000000..3347fbc --- /dev/null +++ b/test/ex/q065_test.clj @@ -0,0 +1,12 @@ +;; https://4clojure.oxal.org/#/problem/065 + +(ns ex.q065-test + (:require [clojure.test :as t] + [ex.q065 :as sut])) + +(t/deftest test-q65 + (t/testing "Problem 65, Black Box Testing" + (t/is (= :map (sut/ans {:a 1, :b 2}))) + (t/is (= :list (sut/ans (range (rand-int 20))))) + (t/is (= :vector (sut/ans [1 2 3 4 5 6]))) + (t/is (= [:map :set :vector :list] (map sut/ans [{} #{} [] ()]))))) \ No newline at end of file