Skip to content

Commit

Permalink
Solve Snack in clojure
Browse files Browse the repository at this point in the history
  • Loading branch information
deniscostadsc committed Nov 12, 2024
1 parent 154cb9a commit 2c99da4
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions solutions/beecrowd/1038/1038.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(ns main
(:require [clojure.string :as str]))

(defn main []
(loop [line (read-line)]
(when line
(let [[n q] (->> (str/split line #" ")
(map #(Integer/parseInt %)))]
(cond
(= n 1)
(printf "Total: R$ %.2f%n", (* 4.0 q))
(= n 2)
(printf "Total: R$ %.2f%n", (* 4.5 q))
(= n 3)
(printf "Total: R$ %.2f%n", (* 5.0 q))
(= n 4)
(printf "Total: R$ %.2f%n", (* 2.0 q))
:else
(printf "Total: R$ %.2f%n", (* 1.5 q))))
(recur (read-line)))))

(main)

0 comments on commit 2c99da4

Please sign in to comment.