Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
deniscostadsc committed Dec 14, 2024
1 parent 108faf9 commit 6a66019
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 92 deletions.
2 changes: 1 addition & 1 deletion solutions/beecrowd/1002/1002.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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))
3 changes: 1 addition & 2 deletions solutions/beecrowd/1011/1011.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion solutions/beecrowd/1012/1012.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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')))
Expand Down
5 changes: 2 additions & 3 deletions solutions/beecrowd/1013/1013.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
[a b]
(-> (- a b)
Math/abs
(+ b)
(+ a)
(/ 2)))
(+ b a)
(/ 2)))

(defn main []
(loop [line (read-line)]
Expand Down
164 changes: 82 additions & 82 deletions solutions/beecrowd/1032/1032.clj
Original file line number Diff line number Diff line change
@@ -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)
3 changes: 1 addition & 2 deletions solutions/beecrowd/1036/1036.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
(defn delta [a b c]
(-> (* b b)
(- 4)
(* a)
(* c)))
(* a c)))

(defn bhaskara [a b delta]
[(-> b
Expand Down
2 changes: 1 addition & 1 deletion solutions/project-euler/001/001.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6a66019

Please sign in to comment.