Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,19 @@
(defn knapsacks []
(let [pan (struct item 3000 0.3 0.025)
ich (struct item 1800 0.2 0.015)
gol (struct item 2500 2.0 0.002)
types [pan ich gol]
max-w 25.0
max-v 0.25
iters #(range (inc (max-count % max-w max-v)))]
(filter (complement nil?)
(pmap
#(let [[p i g] %
w (total :weight types %)
v (total :volume types %)]
(if (and (<= w max-w) (<= v max-v))
(with-meta (struct item (total :value types %) w v) {:p p :i i :g g})))
(for [p (iters pan)
i (iters ich)
g (iters gol)]
[p i g])))))