mirror of
https://github.com/Ajetski/advent-of-code.git
synced 2025-09-30 05:23:17 -09:00
golf
This commit is contained in:
parent
3c65d19b8d
commit
c52b029321
@ -11,9 +11,8 @@
|
||||
;; part 1
|
||||
(->> input
|
||||
c/get-coords
|
||||
(reduce (fn [acc [row col]]
|
||||
(+ acc
|
||||
(->> (for [offset (range 4)]
|
||||
(map (fn [[row col]]
|
||||
(->> (for [offset (range 4)]
|
||||
(map #(apply get-char %)
|
||||
[[row (+ col offset)]
|
||||
[row (- col offset)]
|
||||
@ -26,20 +25,18 @@
|
||||
(apply map vector)
|
||||
(filter #(= % (seq "XMAS")))
|
||||
count)))
|
||||
0))
|
||||
(reduce +))
|
||||
|
||||
;; part 2
|
||||
(->> input
|
||||
c/get-coords
|
||||
(reduce (fn [acc [row col]]
|
||||
(+ acc
|
||||
(if (= (get-char row col) \A)
|
||||
(->> [[[(dec row) (dec col)] [(inc row) (inc col)]]
|
||||
[[(inc row) (dec col)] [(dec row) (inc col)]]]
|
||||
(map (partial map #(apply get-char %)))
|
||||
(map set)
|
||||
(apply = #{\M \S})
|
||||
c/bool->binary)
|
||||
0)))
|
||||
0))
|
||||
(filter #(= (apply get-char %) \A))
|
||||
(map (fn [[row col]]
|
||||
(->> [[[(dec row) (dec col)] [(inc row) (inc col)]]
|
||||
[[(inc row) (dec col)] [(dec row) (inc col)]]]
|
||||
(map (partial map #(apply get-char %)))
|
||||
(map set)
|
||||
(apply = #{\M \S})
|
||||
c/bool->binary)))
|
||||
(reduce +))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user