use regex n-repeat

This commit is contained in:
Adam Jeniski 2024-12-03 00:55:03 -05:00
parent 8a5bba8f29
commit 126b3a4768

View File

@ -10,7 +10,7 @@
returns list of parsed integral multiplication results" returns list of parsed integral multiplication results"
[s] [s]
(->> s (->> s
(re-seq #"mul\((\d\d?\d?),(\d\d?\d?)\)") (re-seq #"mul\((\d{1,3}),(\d{1,3})\)")
(map rest) (map rest)
(map #(map parse-long %)) (map #(map parse-long %))
(map #(reduce * %)))) (map #(reduce * %))))
@ -22,7 +22,7 @@
;; part 2 ;; part 2
(->> input (->> input
(c/re-pos #"mul\((\d\d?\d?),(\d\d?\d?)\)|(do\(\))|(don't\(\))") (c/re-pos #"mul\((\d{1,3}),(\d{1,3})\)|(do\(\))|(don't\(\))")
(sort-by key) (sort-by key)
(reduce (reduce
(fn [acc [_idx instr]] (fn [acc [_idx instr]]