Last active
August 6, 2018 18:42
-
-
Save pjagielski/0b6e69ef4fea4a66cc4ecbd9cc2c3709 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn part [goal] | |
(let [time (first goal)] | |
(cond | |
(<= time 45) 1 | |
(<= time 90) 2 | |
(<= time 105) 3 | |
(<= time 120) 4))) | |
(defn parts [time-str] | |
(->> | |
(string/split time-str #"\+") | |
(map string/trim) | |
(map #(string/replace % #"'" "")) | |
(map #(Integer/parseInt %)))) | |
(defn part-and-time [time-str] | |
(let [parts (parts time-str)] | |
[(part parts) (reduce + parts)])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment