Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save flengyel/1446291 to your computer and use it in GitHub Desktop.
Save flengyel/1446291 to your computer and use it in GitHub Desktop.
Solution to Black Box Testing (4clojure problem 65)
;; flengyel's solution to Black Box Testing
;; https://4clojure.com/problem/65
(fn blackbox [s]
(cond
(= (conj s {}) s) :map
(empty? s) (cond
(= (clojure.set/union s #{}) #{}) :set
(= (conj (conj s 0) 1) [0 1]) :vector
:else :list)
(= (clojure.set/union s s) s) :set
(= (first (conj s s)) s) :list
:else :vector))
@dive2Pro
Copy link

dive2Pro commented Jul 7, 2020

(conj :map {}) = :map

(conj :list 1) = :list

(conj :vector [1] ) = [:vector 1]

; conj list
 (conj `(1) `(1)) = `(`(1) 1)
; conj vector
(conj [1] [1] ) = [1 1]

(union :set #{}) = :set

(union [1] [1]) = [1 1] ;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment