From b71b7d18b5b3d20180b25b7d3f3f9ed0a043ee46 Mon Sep 17 00:00:00 2001 From: Denis Costa Date: Sat, 28 Sep 2024 10:24:59 -0300 Subject: [PATCH] Add unfinished solution --- solutions/beecrowd/1022/1022.clj | 61 ++++++++++++++++++++++++++++++++ solutions/beecrowd/1022/WRONG | 0 2 files changed, 61 insertions(+) create mode 100644 solutions/beecrowd/1022/1022.clj create mode 100644 solutions/beecrowd/1022/WRONG diff --git a/solutions/beecrowd/1022/1022.clj b/solutions/beecrowd/1022/1022.clj new file mode 100644 index 00000000..a407c7a4 --- /dev/null +++ b/solutions/beecrowd/1022/1022.clj @@ -0,0 +1,61 @@ +(ns main + (:require [clojure.string :as str])) + +(defn debug [x] + (println x) + x) +(defn gimme-type [x] + (println (type x)) + x) + +(defn gcd [a b] + (println (type a) " - " (type b)) + (loop [a' a + b' b] + (println (type a') " - " (type b')) + (if (= 0 b') + a' + (recur 'b (mod a' b'))))) + +(defn process-input [line] + (let [[a' _ b' o c' _ d'] (str/split line #" ") + [a b c d] (map #(Integer/parseInt %) [a' b' c' d'])] + (cond + (= o "+") + (-> (* b d) + (* a) + (/ b) + (+ (* b d)) + (* c) + (/ d) + (gcd (* b d))) + (= o "-") + (-> (* b d) + (* a) + (/ b) + (- (* b d)) + (* c) + (/ d) + (gcd (* b d))) + (= o "*") + (-> a + (* c) + (gcd (* b d))) + :else + (-> a + (debug) + (gimme-type) + (* d) + (debug) + (gimme-type) + (gcd (* b c)))))) + +(defn main [] + (let [c (-> (read-line) + (Integer/parseInt))] + (loop [c' c] + (process-input (read-line)) + (when c' + (recur (- c' 1)))))) + +(main) diff --git a/solutions/beecrowd/1022/WRONG b/solutions/beecrowd/1022/WRONG new file mode 100644 index 00000000..e69de29b