From 108faf92348e3aacd506104e29f79b1dfa6f3735 Mon Sep 17 00:00:00 2001 From: Denis Costa Date: Sat, 14 Dec 2024 11:59:37 -0300 Subject: [PATCH] Solve UFPR Gaming in clojure --- solutions/beecrowd/2543/2543.clj | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 solutions/beecrowd/2543/2543.clj diff --git a/solutions/beecrowd/2543/2543.clj b/solutions/beecrowd/2543/2543.clj new file mode 100644 index 00000000..80e89192 --- /dev/null +++ b/solutions/beecrowd/2543/2543.clj @@ -0,0 +1,21 @@ +(ns main + (:require [clojure.string :as str])) + +(defn count-contra-strike-gameplay [n university-id] + (loop [index 0 + count-gameplay 0] + (if (< index n) + (let [[id gameplay] (map #(Integer/parseInt %) (str/split (read-line) #" "))] + (if (and (= id university-id) (= gameplay 0)) + (recur (inc index) (inc count-gameplay)) + (recur (inc index) count-gameplay))) + count-gameplay))) + +(defn main [] + (loop [line (read-line)] + (when line + (let [[n university-id] (map #(Integer/parseInt %) (str/split line #" "))] + (println (count-contra-strike-gameplay n university-id))) + (recur (read-line))))) + +(main)