This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; hyone's solution to Pascal's Triangle | |
;; https://4clojure.com/problem/97 | |
(fn [n] (nth (iterate #(vec (map + (conj % 0) (cons 0 %))) '[1]) (dec n))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; hyone's solution to Symmetric Difference | |
;; https://4clojure.com/problem/88 | |
#(cond | |
(empty? %1) %2 | |
(empty? %2) %1 | |
:else (apply disj (apply conj %1 %2) (filter %1 %2))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; hyone's solution to Merge with a Function | |
;; https://4clojure.com/problem/69 | |
(fn my-merge-with [f & maps] | |
(reduce | |
(fn [a b] | |
(reduce | |
(fn [x [k v]] | |
(assoc x k (if (b k) (f v (b k)) v))) | |
b a)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; hyone's solution to Black Box Testing | |
;; https://4clojure.com/problem/65 | |
(defn seq-type [coll] | |
(let [base (empty coll)] | |
(cond | |
(= base {}) :map | |
(= base #{}) :set | |
(= base '()) (if (reversible? coll) :vector :list)))) |