This commit is contained in:
Adam Jeniski 2024-12-05 22:03:32 -05:00
parent b9943d7138
commit 29bf59df8f
3 changed files with 12 additions and 7 deletions

View File

@ -27,10 +27,15 @@
col (range (count (get list-of-lists row)))]
[row col]))
(defn insert-vec [v idx el]
(into [] (concat (take idx v)
(defn insert-at-idx [coll idx el]
(concat (take idx coll)
(list el)
(drop idx v))))
(drop idx coll)))
(defn bool->binary [condition]
(if condition 1 0))
(defn mmap
"map map"
[f coll]
(map (partial map f) coll))

View File

@ -20,7 +20,7 @@
[(- row offset) (+ col offset)]
[(+ row offset) (- col offset)]
[(+ row offset) (+ col offset)]])
(map (partial map get-char))
(c/mmap get-char)
(apply map vector)
(filter #(= % (seq "XMAS")))
count)))
@ -32,7 +32,7 @@
(filter (fn [[row col]]
(->> [[[(dec row) (dec col)] [(inc row) (inc col)]]
[[(inc row) (dec col)] [(dec row) (inc col)]]]
(map (partial map get-char))
(c/mmap get-char)
(map set)
(apply = #{\M \S}))))
count)

View File

@ -31,7 +31,7 @@
(map #(.indexOf acc %))
(filter #(not= % -1))
not-empty)]
(c/insert-vec acc (apply min idxs) el)
(into [] (c/insert-at-idx acc (apply min idxs) el))
(conj acc el)))
[] coll))