diff options
Diffstat (limited to 'day9/part1.clj')
-rw-r--r-- | day9/part1.clj | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/day9/part1.clj b/day9/part1.clj new file mode 100644 index 0000000..813d5a6 --- /dev/null +++ b/day9/part1.clj @@ -0,0 +1,37 @@ +(def input-map + (->> (slurp "./in") + (clojure.string/split-lines) + (mapv vec) + (mapv (partial mapv #(- (int %) 48))) + )) + +(defn compare-heights [a b] + (if (or (nil? a) (nil? b) (< a b)) 1 0)) + +(println + (apply + + (for [y (range 0 (count input-map)) + x (range 0 (count (first input-map)))] + (let [height (get-in input-map [y x])] + (if + (= 4 + (apply + + (map + (partial compare-heights height) + [ + (get-in input-map [(dec y) x]) + (get-in input-map [(inc y) x]) + (get-in input-map [y (dec x)]) + (get-in input-map [y (inc x)]) + ] + ) + ) + ) + (inc height) + 0 + ) + ) + ) + ) + ) + |