Skip to content

Instantly share code, notes, and snippets.

@chrisguitarguy
Last active March 25, 2016 17:41
Show Gist options
  • Select an option

  • Save chrisguitarguy/40505541aed567407d09 to your computer and use it in GitHub Desktop.

Select an option

Save chrisguitarguy/40505541aed567407d09 to your computer and use it in GitHub Desktop.
(require '[clojure.string :as string])
(defn- str->int [s]
(Integer/parseInt s))
(defn- split-spaces [s]
(string/split s #"\s+"))
(defn- read-test-case []
(let [[students threshold] (split-spaces (read-line))
arrivals (split-spaces (read-line))]
{:students (str->int students)
:threshold (str->int threshold)
:arrivals (map str->int arrivals)}))
(defn- students-at-start [test-case]
(count (filter #(<= % 0) (:arrivals test-case))))
(defn- class-canceled? [test-case]
(< (students-at-start test-case) (:threshold test-case)))
(defn -main [& args]
(let [tc-count (str->int (read-line))
test-cases (repeatedly tc-count read-test-case)]
(doseq [test-case test-cases]
(println (if (class-canceled? test-case) "YES" "NO")))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment