RosettaCodeData/Task/Knapsack-problem-Unbounded/Clojure/knapsack-problem-unbounded-1.clj

10 lines
276 B
Clojure
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
(defstruct item :value :weight :volume)
(defn total [key items quantities]
(reduce + (map * quantities (map key items))))
(defn max-count [item max-weight max-volume]
(let [mcw (/ max-weight (:weight item))
mcv (/ max-volume (:volume item))]
(min mcw mcv)))