mirror of
https://github.com/Ajetski/advent-of-code.git
synced 2025-09-30 07:03:19 -09:00
use regex n-repeat
This commit is contained in:
parent
8a5bba8f29
commit
126b3a4768
@ -10,7 +10,7 @@
|
||||
returns list of parsed integral multiplication results"
|
||||
[s]
|
||||
(->> s
|
||||
(re-seq #"mul\((\d\d?\d?),(\d\d?\d?)\)")
|
||||
(re-seq #"mul\((\d{1,3}),(\d{1,3})\)")
|
||||
(map rest)
|
||||
(map #(map parse-long %))
|
||||
(map #(reduce * %))))
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
;; part 2
|
||||
(->> 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)
|
||||
(reduce
|
||||
(fn [acc [_idx instr]]
|
||||
|
Loading…
x
Reference in New Issue
Block a user