This commit is contained in:
Adam Jeniski 2024-12-04 23:13:30 -05:00
parent b25e12b3a2
commit 3c65d19b8d
2 changed files with 29 additions and 30 deletions

View File

@ -28,7 +28,8 @@
(->> list-of-lists count range (->> list-of-lists count range
(map #(->> % (get list-of-lists) count range)) (map #(->> % (get list-of-lists) count range))
(map-indexed (fn [row cols] (map-indexed (fn [row cols]
(map #(list row %) cols))))) (map #(list row %) cols)))
(mapcat identity)))
(defn bool->binary [condition] (defn bool->binary [condition]
(if condition 1 0)) (if condition 1 0))

View File

@ -11,7 +11,7 @@
;; part 1 ;; part 1
(->> input (->> input
c/get-coords c/get-coords
(map (partial reduce (fn [acc [row col]] (reduce (fn [acc [row col]]
(+ acc (+ acc
(->> (for [offset (range 4)] (->> (for [offset (range 4)]
(map #(apply get-char %) (map #(apply get-char %)
@ -27,12 +27,11 @@
(filter #(= % (seq "XMAS"))) (filter #(= % (seq "XMAS")))
count))) count)))
0)) 0))
(reduce +))
;; part 2 ;; part 2
(->> input (->> input
c/get-coords c/get-coords
(map (partial reduce (fn [acc [row col]] (reduce (fn [acc [row col]]
(+ acc (+ acc
(if (= (get-char row col) \A) (if (= (get-char row col) \A)
(->> [[[(dec row) (dec col)] [(inc row) (inc col)]] (->> [[[(dec row) (dec col)] [(inc row) (inc col)]]
@ -43,5 +42,4 @@
c/bool->binary) c/bool->binary)
0))) 0)))
0)) 0))
(reduce +))