-
-
Save weavejester/040fa26b7fc1918f9144 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[clojure.string :as str]) | |
(defn parse-ints [line] | |
(for [s (str/split line #" ")] (Integer/parseInt s))) | |
(defn read-service-data [] | |
(let [[n t] (parse-ints (read-line))] | |
{:widths (parse-ints (read-line)) | |
:tests (->> (repeatedly read-line) (take n) (map parse-ints))})) | |
(defn slice [coll [start end]] | |
(drop start (take (inc end) widths)))) | |
(defn find-mins [{:keys [widths tests]}] | |
(for [t tests] (apply min (slice widths t)))) | |
(doseq [m (find-mins (read-service-data))] | |
(println m)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment