diff --git a/src/i_am_a_horse_in_the_land_of_booleans.clj b/src/i_am_a_horse_in_the_land_of_booleans.clj index 66a18e7a..db4fee4c 100644 --- a/src/i_am_a_horse_in_the_land_of_booleans.clj +++ b/src/i_am_a_horse_in_the_land_of_booleans.clj @@ -2,27 +2,62 @@ (:refer-clojure :exclude [boolean])) (defn boolean [x] - ":(") + (if (or (= x nil) (= x false)) + false + true + )) (defn abs [x] - ":(") + (if (< x 0) + (- x) + x + )) (defn divides? [divisor n] - ":(") + (if (= (mod n divisor) 0) + true + false + )) (defn fizzbuzz [n] - ":(") + (cond + (divides? 15 n) "gotcha!" + (divides? 3 n) "fizz" + (divides? 5 n) "buzz" + :else "" + ) +) (defn teen? [age] - ":(") + (if (< 12 age 20) + true + false + )) (defn not-teen? [age] - ":(") + (not (teen? age))) (defn generic-doublificate [x] - ":(") + (cond + (number? x) (* 2 x) + (empty? x) nil + (or (list? x) (vector? x)) (* 2 (count x)) + :else true + ) +) (defn leap-year? [year] - ":(") + (if + (and + (divides? 4 year) + (or + (not (divides? 100 year)) + (divides? 400 year) + ) + ) + true + false + ) +) ; '_______'