diff --git a/.gitignore b/.gitignore index ee508f76..a4ad3bc7 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ pom.xml .lein-deps-sum .lein-failures .lein-plugins +/bin/ 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..b7dee1c9 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,53 @@ (:refer-clojure :exclude [boolean])) (defn boolean [x] - ":(") + (if x + true + false)) (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? 5 n) "buzz" + (divides? 3 n) "fizz" + :else "")) (defn teen? [age] - ":(") + (if (<= 13 age 19) + true + false)) (defn not-teen? [age] - ":(") + (if (<= 13 age 19) + false + true)) (defn generic-doublificate [x] - ":(") + (cond + (number? x)(* x 2) + (empty? x) nil + (list? x)(* (count x) 2) + (vector? x)(* (count x) 2) + :else true)) (defn leap-year? [year] - ":(") + (cond + (divides? 100 year) + (cond + (divides? 400 year) true + :else false) + (divides? 4 year) true + :else false)) + ; '_______'