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