mirror of
https://github.com/Ajetski/advent-of-code.git
synced 2025-09-30 13:03:19 -09:00
golf
This commit is contained in:
parent
ff09b6d9dc
commit
e1650bd8f6
@ -5,26 +5,23 @@
|
|||||||
|
|
||||||
(def input (->> (get-puzzle-input 6)))
|
(def input (->> (get-puzzle-input 6)))
|
||||||
|
|
||||||
(defn ways-to-beat [[ms record]]
|
(defn solve [num-str-lists]
|
||||||
(->> (range 1 ms)
|
(->> (map (partial map #(Long/parseLong %)) num-str-lists)
|
||||||
(pmap #(* % (- ms %)))
|
(apply zipmap)
|
||||||
(filter #(> % record))
|
(map (fn [[ms record]] (->> (range 1 ms)
|
||||||
(count)))
|
(map #(* % (- ms %)))
|
||||||
|
(filter #(> % record))
|
||||||
|
(count))))
|
||||||
|
(reduce *)))
|
||||||
|
|
||||||
;; part 1
|
;; part 1
|
||||||
(->> input
|
(->> input
|
||||||
(map (partial re-seq #"\d+"))
|
(map (partial re-seq #"\d+"))
|
||||||
(map (partial map #(Long/parseLong %)))
|
solve)
|
||||||
(apply zipmap)
|
|
||||||
(map ways-to-beat)
|
|
||||||
(reduce *))
|
|
||||||
|
|
||||||
;; part 2
|
;; part 2
|
||||||
(->> input
|
(->> input
|
||||||
(map (partial re-seq #"[\s\d]+"))
|
(map (partial re-seq #"[\s\d]+"))
|
||||||
(map (partial map #(string/replace % " " "")))
|
(map (partial map #(string/replace % " " "")))
|
||||||
(map (partial map #(Long/parseLong %)))
|
solve)
|
||||||
(apply zipmap)
|
|
||||||
(map ways-to-beat)
|
|
||||||
(reduce *))
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user