diff --git a/solutions/beecrowd/1002/1002.clj b/solutions/beecrowd/1002/1002.clj index eb135fc1..e8022bf6 100644 --- a/solutions/beecrowd/1002/1002.clj +++ b/solutions/beecrowd/1002/1002.clj @@ -2,6 +2,6 @@ (defn main [] (let [n (Double/parseDouble (read-line))] - (format "%.4f" (* (* n n) 3.14159)))) + (format "%.4f" (* n n 3.14159)))) (printf "A=%s%n" (main)) diff --git a/solutions/beecrowd/1011/1011.clj b/solutions/beecrowd/1011/1011.clj index d9528a3a..ff99b3d9 100644 --- a/solutions/beecrowd/1011/1011.clj +++ b/solutions/beecrowd/1011/1011.clj @@ -8,8 +8,7 @@ (let [radius (Double/parseDouble line)] (printf "VOLUME = %.3f%n" (-> (/ 4.0 3.0) - (* pi) - (* (Math/pow radius 3))))) + (* pi (Math/pow radius 3))))) (recur (read-line))))) (main) diff --git a/solutions/beecrowd/1012/1012.clj b/solutions/beecrowd/1012/1012.clj index 37d07944..cd40eceb 100644 --- a/solutions/beecrowd/1012/1012.clj +++ b/solutions/beecrowd/1012/1012.clj @@ -11,7 +11,7 @@ b' (Double/parseDouble b) c' (Double/parseDouble c)] (printf "TRIANGULO: %.3f%n" (/ (* a' c') 2)) - (printf "CIRCULO: %.3f%n" (* pi (* c' c'))) + (printf "CIRCULO: %.3f%n" (* pi c' c')) (printf "TRAPEZIO: %.3f%n" (* (/ (+ a' b') 2) c')) (printf "QUADRADO: %.3f%n" (* b' b')) (printf "RETANGULO: %.3f%n" (* a' b'))) diff --git a/solutions/beecrowd/1013/1013.clj b/solutions/beecrowd/1013/1013.clj index 28a3a81e..8773b6de 100644 --- a/solutions/beecrowd/1013/1013.clj +++ b/solutions/beecrowd/1013/1013.clj @@ -5,9 +5,8 @@ [a b] (-> (- a b) Math/abs - (+ b) - (+ a) - (/ 2))) + (+ b a) + (/ 2))) (defn main [] (loop [line (read-line)] diff --git a/solutions/beecrowd/1032/1032.clj b/solutions/beecrowd/1032/1032.clj index 8e0aa058..28777b8a 100644 --- a/solutions/beecrowd/1032/1032.clj +++ b/solutions/beecrowd/1032/1032.clj @@ -1,95 +1,95 @@ -(ns main) +;; (ns main) -(defn divisible? [number divisor] - (zero? (rem number divisor))) +;; (defn divisible? [number divisor] +;; (zero? (rem number divisor))) -(def prime? - (memoize (fn [number] - (cond (= number 2) - true - (or (< number 2) (divisible? number 2)) - false - :else - (not-any? #(divisible? number %) (range - 3 - (-> (Math/sqrt number) - Math/ceil - int - inc) - 2)))))) +;; (def prime? +;; (memoize (fn [number] +;; (cond (= number 2) +;; true +;; (or (< number 2) (divisible? number 2)) +;; false +;; :else +;; (not-any? #(divisible? number %) (range +;; 3 +;; (-> (Math/sqrt number) +;; Math/ceil +;; int +;; inc) +;; 2)))))) -(def next-prime - (memoize (fn [number] - (let [next-number (inc number)] - (if (prime? next-number) - next-number - (next-prime (inc number))))))) +;; (def next-prime +;; (memoize (fn [number] +;; (let [next-number (inc number)] +;; (if (prime? next-number) +;; next-number +;; (next-prime (inc number))))))) -(def nth-prime - (memoize (fn [nth] - (loop [index 0 - prime 2] - (cond (= nth 0) - 2 - (= index (dec nth)) - (next-prime prime) - :else - (recur (inc index) - (next-prime prime))))))) +;; (def nth-prime +;; (memoize (fn [nth] +;; (loop [index 0 +;; prime 2] +;; (cond (= nth 0) +;; 2 +;; (= index (dec nth)) +;; (next-prime prime) +;; :else +;; (recur (inc index) +;; (next-prime prime))))))) -;; (def josephus -;; (memoize (fn [n k] -;; (if (= n 1) -;; 1 -;; (-> (josephus (dec n) (next-prime k)) -;; (+ k) -;; (dec) -;; (mod n) -;; (inc)))))) +;; ;; (def josephus +;; ;; (memoize (fn [n k] +;; ;; (if (= n 1) +;; ;; 1 +;; ;; (-> (josephus (dec n) (next-prime k)) +;; ;; (+ k) +;; ;; (dec) +;; ;; (mod n) +;; ;; (inc)))))) -(defn josephus [n] - (loop [current-n 1 - ;; index-prime 0 - result 1] - (printf "prime: %d > %d%n" (- n current-n) (nth-prime (- n current-n))) - (printf "current-n: %d%n" current-n) - (printf "result: %d%n" result) - (printf "--%n") - (cond (= n 1) - 1 - (= current-n (inc n)) - result - :else - (recur (inc current-n) - ;; (inc index-prime) - (-> result - (+ (nth-prime (- n current-n))) - dec - (mod current-n) - inc)))) +;; (defn josephus [n] +;; (loop [current-n 1 +;; ;; index-prime 0 +;; result 1] +;; (printf "prime: %d > %d%n" (- n current-n) (nth-prime (- n current-n))) +;; (printf "current-n: %d%n" current-n) +;; (printf "result: %d%n" result) +;; (printf "--%n") +;; (cond (= n 1) +;; 1 +;; (= current-n (inc n)) +;; result +;; :else +;; (recur (inc current-n) +;; ;; (inc index-prime) +;; (-> result +;; (+ (nth-prime (- n current-n))) +;; dec +;; (mod current-n) +;; inc)))) -(defn main [] - (loop [number (Integer/parseInt (read-line))] - (printf "-----------%n") - (when (not= number 0) - (printf "%d%n" (josephus number)) - (recur (Integer/parseInt (read-line)))))) +;; (defn main [] +;; (loop [number (Integer/parseInt (read-line))] +;; (printf "-----------%n") +;; (when (not= number 0) +;; (printf "%d%n" (josephus number)) +;; (recur (Integer/parseInt (read-line)))))) -(main) +;; (main) -(defn print-primes [] - (loop [n 2] - (when (<= n 200) - (printf "%d -> %d%n" n (next-prime n)) - (recur (next-prime n))))) +;; (defn print-primes [] +;; (loop [n 2] +;; (when (<= n 200) +;; (printf "%d -> %d%n" n (next-prime n)) +;; (recur (next-prime n))))) -;; (print-primes) +;; ;; (print-primes) -(defn print-nth-primes [] - (loop [n 0] - (when (<= n 200) - (printf "%d -> %d%n" n (nth-prime n)) - (recur (inc n))))) +;; (defn print-nth-primes [] +;; (loop [n 0] +;; (when (<= n 200) +;; (printf "%d -> %d%n" n (nth-prime n)) +;; (recur (inc n))))) -;; (print-nth-primes) +;; ;; (print-nth-primes) diff --git a/solutions/beecrowd/1036/1036.clj b/solutions/beecrowd/1036/1036.clj index 30d0e4e4..eb120a12 100644 --- a/solutions/beecrowd/1036/1036.clj +++ b/solutions/beecrowd/1036/1036.clj @@ -4,8 +4,7 @@ (defn delta [a b c] (-> (* b b) (- 4) - (* a) - (* c))) + (* a c))) (defn bhaskara [a b delta] [(-> b diff --git a/solutions/project-euler/001/001.clj b/solutions/project-euler/001/001.clj index 02496d13..8d19bbe7 100644 --- a/solutions/project-euler/001/001.clj +++ b/solutions/project-euler/001/001.clj @@ -3,7 +3,7 @@ (defn sum-all-divibles-by [n limit] (let [p (quot limit n)] - (quot (* n (* p (+ p 1))) 2))) + (quot (* n p (+ p 1)) 2))) (defn main [] (- (+ (sum-all-divibles-by 3 999)