From 692b8ac7245a99efd3d69ec1457c25f866ecd374 Mon Sep 17 00:00:00 2001 From: Madison Tibbett Date: Fri, 19 Oct 2018 20:39:34 -0400 Subject: [PATCH] tests pass --- src/i_am_a_horse_in_the_land_of_booleans.clj | 43 +++++++++++++++----- 1 file changed, 33 insertions(+), 10 deletions(-) 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..0a21027e 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,50 @@ (: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 + (== (mod n 15) 0) "gotcha!" + (== (mod n 3) 0) "fizz" + (== (mod n 5) 0) "buzz" + :else "")) (defn teen? [age] - ":(") + (<= 13 age 19)) (defn not-teen? [age] - ":(") + (if (not (teen? age)) + true + false)) (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] - ":(") - -; '_______' + (if (< year 100) + (if ( == (mod year 4) 0) + true + false) + (if ( == (mod year 100) 0) + (if ( == (mod year 400) 0) + true + false)))) + + + ; '_______'