mirror of
https://github.com/Ajetski/advent-of-code.git
synced 2025-09-30 11:23:17 -09:00
refactor
This commit is contained in:
parent
91b43fae83
commit
1f5cc1cf5e
@ -1,4 +1,12 @@
|
|||||||
(ns core)
|
(ns core
|
||||||
|
(:require
|
||||||
|
[clojure.string :as str]))
|
||||||
|
|
||||||
(defn compose [& fs]
|
(defn compose [& fs]
|
||||||
(apply comp (reverse fs)))
|
(apply comp (reverse fs)))
|
||||||
|
|
||||||
|
(defn split-whitespace [s]
|
||||||
|
(str/split s #"\s+"))
|
||||||
|
|
||||||
|
(defn get-match-groups [regex s]
|
||||||
|
(->> s (re-seq regex) first rest))
|
||||||
|
@ -4,9 +4,8 @@
|
|||||||
[core :as c]))
|
[core :as c]))
|
||||||
|
|
||||||
(def input (->> (get-input 1)
|
(def input (->> (get-input 1)
|
||||||
(map (c/compose #(re-seq #"(\d+)\s+(\d+)" %)
|
(map #(c/get-match-groups #"(\d+)\s+(\d+)" %))
|
||||||
first rest ; only get match groups
|
(map #(mapv parse-long %))
|
||||||
#(mapv parse-long %)))
|
|
||||||
(into {})
|
(into {})
|
||||||
((juxt keys vals))))
|
((juxt keys vals))))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user