You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
558 B
Clojure

(def input-map
(->> (slurp "./in")
(clojure.string/split-lines)
(mapv vec)
(mapv (partial mapv #(- (int %) 48)))
))
(defn get-adj [y x]
(map (partial get-in input-map)
[[(dec y) x] [(inc y) x] [y (dec x)] [y (inc x)]]))
(->> (for [y (range 0 (count input-map))
x (range 0 (count (first input-map)))
:let [height (get-in input-map [y x])]
:when (every? #(or (nil? %) (< height %))
(get-adj y x))]
(inc height))
(apply +)
(println)
)