aboutsummaryrefslogtreecommitdiffstats
path: root/year2021/day9/part1.clj
diff options
context:
space:
mode:
Diffstat (limited to 'year2021/day9/part1.clj')
-rw-r--r--year2021/day9/part1.clj21
1 files changed, 21 insertions, 0 deletions
diff --git a/year2021/day9/part1.clj b/year2021/day9/part1.clj
new file mode 100644
index 0000000..7bd8e23
--- /dev/null
+++ b/year2021/day9/part1.clj
@@ -0,0 +1,21 @@
+(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)
+ )
+