Skip to content

Instantly share code, notes, and snippets.

@pjagielski
Last active August 6, 2018 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pjagielski/0b6e69ef4fea4a66cc4ecbd9cc2c3709 to your computer and use it in GitHub Desktop.
Save pjagielski/0b6e69ef4fea4a66cc4ecbd9cc2c3709 to your computer and use it in GitHub Desktop.
(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