improve naming

This commit is contained in:
Adam Jeniski 2023-12-03 12:51:49 -05:00
parent 7396fcc6d1
commit 9ddce5f7a8

View File

@ -40,7 +40,7 @@
(map #(vector row (:start %) (:group %)) (map #(vector row (:start %) (:group %))
matches))) matches)))
(mapcat identity) (mapcat identity)
(map (fn touching-star [[row-idx col-idx s]] (map (fn touching-stars [[row-idx col-idx s]]
(let [length (count s)] (let [length (count s)]
(->> (for [r [(dec row-idx) row-idx (inc row-idx)] (->> (for [r [(dec row-idx) row-idx (inc row-idx)]
c (range (dec col-idx) (+ col-idx length 1))] c (range (dec col-idx) (+ col-idx length 1))]
@ -51,7 +51,7 @@
(filter seq) (filter seq)
(mapcat identity) (mapcat identity)
(map #(vector (ffirst %) (second %)))) (map #(vector (ffirst %) (second %))))
cogs (->> data gear (->> data
(map first) (map first)
(frequencies) (frequencies)
(filter #(= (second %) 2)) (filter #(= (second %) 2))
@ -59,7 +59,7 @@
(into #{}))] (into #{}))]
(->> data (->> data
(group-by first) (group-by first)
(filter #(cogs (first %))) (filter #(gear (first %)))
(map #(update % 1 (partial map second))) (map #(update % 1 (partial map second)))
(map second) (map second)
(map (partial map #(Integer/parseInt %))) (map (partial map #(Integer/parseInt %)))