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..bd418188 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,39 @@ (:refer-clojure :exclude [boolean])) (defn boolean [x] - ":(") + (if x + true + false)) (defn abs [x] - ":(") + (if (> x 0) + x + (- x))) (defn divides? [divisor n] - ":(") + (= 0 (mod n divisor))) (defn fizzbuzz [n] - ":(") + (cond + (divides? 15 n) "gotcha!" + (divides? 5 n) "buzz" + (divides? 3 n) "fizz" + :else "")) (defn teen? [age] - ":(") + (< 12 age 20)) (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] - ":(") + (or (divides? 400 year) (and (divides? 4 year) (not (divides? 100 year))))) ; '_______'