simplify
This commit is contained in:
parent
d853e89137
commit
5289e1dfdf
@ -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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user