This commit is contained in:
Adam Jeniski 2025-12-05 20:34:10 -10:00
parent d853e89137
commit 5289e1dfdf

View File

@ -6,14 +6,15 @@
(def num-line? (comp not #{\* \+} first)) (def num-line? (comp not #{\* \+} first))
(def nums-raw (take-while num-line? input)) (def nums-raw (take-while num-line? input))
(def nums (->> nums-raw (def nums (map (comp (partial map parse-long)
(map #(map parse-long (re-seq #"\d+" %))))) #(re-seq #"\d+" %))
nums-raw))
(def op-map {\+ +, \* *}) (def op-map {\+ +, \* *})
(def ops (as-> input v (def ops (->> input
(drop-while num-line? v) (drop-while num-line?)
(first v) (first)
(filter (partial not= \space) v) (filter (partial not= \space))
(mapv op-map v))) (mapv op-map)))
;; part 1 ;; part 1
(->> nums (->> nums