Skip to content

Commit

Permalink
Add q65
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkun committed Sep 6, 2024
1 parent f390400 commit d42a687
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/ex/q065.clj
Original file line number Diff line number Diff line change
@@ -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))
12 changes: 12 additions & 0 deletions test/ex/q065_test.clj
Original file line number Diff line number Diff line change
@@ -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 [{} #{} [] ()])))))

0 comments on commit d42a687

Please sign in to comment.