Skip to content

Instantly share code, notes, and snippets.

@weavejester
Forked from ewingd/gist:f71cf27b90bd231d179b
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weavejester/040fa26b7fc1918f9144 to your computer and use it in GitHub Desktop.
Save weavejester/040fa26b7fc1918f9144 to your computer and use it in GitHub Desktop.
(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