mirror of
https://github.com/Ajetski/advent-of-code.git
synced 2025-09-30 09:23:17 -09:00
refactor
This commit is contained in:
parent
b9943d7138
commit
29bf59df8f
@ -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))
|
||||||
|
@ -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)
|
||||||
|
@ -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))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user