Created
November 25, 2024 16:58
-
-
Save jamtur01/674c681088414f2d01292cd5ae971e02 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 meal-prep | |
"Calculate minimum hours needed to cook meals given prep times in minutes. | |
Each meal must be cooked for its full duration (rounded up to nearest hour). | |
Up to 2 meals can be cooked simultaneously. | |
Args: | |
prep-times - Collection of meal preparation times in minutes | |
Returns: | |
Minimum hours needed to cook all meals" | |
[prep-times] | |
{:pre [(seq prep-times) | |
(every? pos? prep-times)]} | |
(let [hours (->> prep-times | |
(map #(Math/ceil (/ % 60.0))) | |
(into [])) | |
total-slots (reduce + hours) | |
max-single-meal (reduce max hours)] | |
(int (max max-single-meal | |
(Math/ceil (/ total-slots 2)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment