Created
June 11, 2019 14:58
-
-
Save Tavistock/a1c3adf631dbf07de36765beda65038f 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
(declare fill) | |
(defn fill* | |
([k ri] (fill k ri [])) | |
([k ri si] | |
(let [{:keys [w] :as ci} (first ri) | |
rr (rest ri)] | |
(cond | |
(nil? ci) si | |
(< k w) (fill k rr si) | |
:else (max-key sum-v | |
(fill (- k w) rr (conj si ci)) | |
(fill k rr si)))))) | |
(def fill (memoize fill*)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment