Last active
May 13, 2016 17:22
-
-
Save 6ewis/1b4cdedbcc648c3da1d6ab2bb2e0c022 to your computer and use it in GitHub Desktop.
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
Solutions: | |
_pcl's solution: | |
#(if | |
(and (associative? %) (< 1 (count (flatten (list (last (seq (assoc % 0 1))))))) ) :map | |
(let [c (conj % :a :b :c)] | |
(cond | |
(= (take-last 3 c) [:a :b :c]) :vector | |
(= (take 3 c) [:c :b :a]) :list | |
true :set))) | |
jimm's solution: | |
; Hack! | |
(fn [x] | |
(or (get {\{ :map \# :set \[ :vector \( :list} (first (str x))) | |
:list)) | |
_caterpillar's solution: | |
#(if (= % (merge % %)) :map | |
(let [extended (conj % :first :second)] | |
(cond | |
(= extended (into extended extended)) :set | |
(= (first extended) :second) :list | |
:else :vector))) | |
austintaylor's solution: | |
(comp {\# :set \{ :map \[ :vector \c :list} first str) | |
jeff_terrell's solution: | |
#(cond | |
(reversible? %) :vector | |
(associative? %) :map | |
(= [2 1] (seq (conj (empty %) 1 2))) :list | |
:else :set) | |
ozan's solution: | |
#(let [t (conj (empty %) [:k :v])] | |
(cond | |
(:k t) :map | |
(get t 0) :vector | |
(get t [:k :v]) :set | |
:else :list)) | |
norman's solution: | |
(fn [x] | |
(let [sym (gensym) sym2 (gensym)] | |
(cond | |
(contains? (conj x [sym sym]) sym) :map | |
(= 1 (count (filter #(= sym %) (conj (conj x sym) sym)))) :set | |
(= sym (first (conj (conj x sym2) sym))) :list | |
:else :vector))) | |
eraserhd's solution: | |
(fn [s] | |
(cond | |
(= :map-value (:map-key (conj s [:map-key :map-value]))) :map | |
(= :list-head (first (conj (conj s :aaa) :list-head))) :list | |
(let [s2 (conj (conj s :set-entry) :set-entry)] | |
(= (count s2) (+ 1 (count s)))) :set | |
:else :vector)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment