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)))] col (range (count (get list-of-lists row)))]
[row col])) [row col]))
(defn insert-vec [v idx el] (defn insert-at-idx [coll idx el]
(into [] (concat (take idx v) (concat (take idx coll)
(list el) (list el)
(drop idx v)))) (drop idx coll)))
(defn bool->binary [condition] (defn bool->binary [condition]
(if condition 1 0)) (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)] [(+ row offset) (- col offset)]
[(+ row offset) (+ col offset)]]) [(+ row offset) (+ col offset)]])
(map (partial map get-char)) (c/mmap get-char)
(apply map vector) (apply map vector)
(filter #(= % (seq "XMAS"))) (filter #(= % (seq "XMAS")))
count))) count)))
@ -32,7 +32,7 @@
(filter (fn [[row col]] (filter (fn [[row col]]
(->> [[[(dec row) (dec col)] [(inc row) (inc col)]] (->> [[[(dec row) (dec col)] [(inc row) (inc col)]]
[[(inc row) (dec col)] [(dec row) (inc col)]]] [[(inc row) (dec col)] [(dec row) (inc col)]]]
(map (partial map get-char)) (c/mmap get-char)
(map set) (map set)
(apply = #{\M \S})))) (apply = #{\M \S}))))
count) count)

View File

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