From 05a045c74e5b248ee534681dd6288bdb9afb1651 Mon Sep 17 00:00:00 2001 From: Denis Costa Date: Wed, 6 Nov 2024 07:10:40 -0300 Subject: [PATCH] Solve Selection Test 1 in clojure --- solutions/beecrowd/1035/1035.clj | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 solutions/beecrowd/1035/1035.clj diff --git a/solutions/beecrowd/1035/1035.clj b/solutions/beecrowd/1035/1035.clj new file mode 100644 index 00000000..6fe157f8 --- /dev/null +++ b/solutions/beecrowd/1035/1035.clj @@ -0,0 +1,22 @@ +(ns main + (:require [clojure.string :as str])) + +(defn accepted-values? [a b c d] + (and (> b c) + (> d a) + (> (+ c d) (+ a b)) + (> c 0) + (> d 0) + (zero? (mod a 2)))) + +(defn main [] + (loop [line (read-line)] + (when line + (let [[a b c d] (->> (str/split line #" ") + (map #(Integer/parseInt %)))] + (if (accepted-values? a b c d) + (printf "Valores aceitos%n") + (printf "Valores nao aceitos%n")) + (recur (read-line)))))) + +(main)