From c130b7bf1c0dfa71a0fde657d9712332162ac824 Mon Sep 17 00:00:00 2001 From: barany Date: Tue, 19 May 2020 20:05:15 +0200 Subject: [PATCH] Initial commit --- src/i_am_a_horse_in_the_land_of_booleans.clj | 38 +++++++++++++++----- 1 file changed, 30 insertions(+), 8 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..856e0462 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,49 @@ (:refer-clojure :exclude [boolean])) (defn boolean [x] - ":(") + (if x true false)) (defn abs [x] - ":(") + (if (< x 0) + (- x) + x)) (defn divides? [divisor n] - ":(") + (= (mod n divisor) 0)) (defn fizzbuzz [n] - ":(") + (cond + (divides? 15 n) "gotcha!" + (divides? 3 n) "fizz" + (divides? 5 n) "buzz" + :else "" + )) (defn teen? [age] - ":(") + (<= 13 age 19)) (defn not-teen? [age] - ":(") + (not (teen? age)) + ) (defn generic-doublificate [x] - ":(") + (cond + (number? x) (* 2 x) + (empty? x) nil + (list? x) (* 2 (count x)) + (vector? x) (* 2 (count x)) + :else true) + ) (defn leap-year? [year] - ":(") + (if (divides? 4 year) + (cond + (divides? 400 year) true + (divides? 100 year) false + :else true + ) + false + ) + ) ; '_______'