mirror of
https://github.com/Ajetski/advent-of-code.git
synced 2025-09-30 13:03:19 -09:00
do day 6
This commit is contained in:
parent
e6b4ec3707
commit
051638cda0
30
2023/src/day06.clj
Normal file
30
2023/src/day06.clj
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
(ns ^{:doc "Day 6"
|
||||||
|
:author "Adam Jeniski"}
|
||||||
|
day06 (:require [clojure.string :as string]
|
||||||
|
[core :refer [get-puzzle-input]]))
|
||||||
|
|
||||||
|
(def input (->> (get-puzzle-input 6)))
|
||||||
|
|
||||||
|
(defn ways-to-beat [[ms record]]
|
||||||
|
(->> (range 1 ms)
|
||||||
|
(pmap #(* % (- ms %)))
|
||||||
|
(filter #(> % record))
|
||||||
|
(count)))
|
||||||
|
|
||||||
|
;; part 1
|
||||||
|
(->> input
|
||||||
|
(map (partial re-seq #"\d+"))
|
||||||
|
(map (partial map #(Long/parseLong %)))
|
||||||
|
(apply zipmap)
|
||||||
|
(map ways-to-beat)
|
||||||
|
(reduce *))
|
||||||
|
|
||||||
|
;; part 2
|
||||||
|
(->> input
|
||||||
|
(map (partial re-seq #"[\s\d]+"))
|
||||||
|
(map (partial map #(string/replace % " " "")))
|
||||||
|
(map (partial map #(Long/parseLong %)))
|
||||||
|
(apply zipmap)
|
||||||
|
(map ways-to-beat)
|
||||||
|
(reduce *))
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user