Data update

This commit is contained in:
Ingy döt Net 2024-10-16 18:07:41 -07:00
parent 81fd053722
commit 52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions

View file

@ -0,0 +1,31 @@
names$[] = [ "panacea" "ichor" "gold" ]
vals[] = [ 3000 1800 2500 ]
wgts[] = [ 0.3 0.2 2.0 ]
vols[] = [ 0.025 0.015 0.002 ]
maxwgt = 25
maxvol = 0.25
#
n = len names$[]
len cnt[] n
global best[] bestval .
#
proc knapsack i val wgt vol . .
if i > n
if val > bestval
bestval = val
best[] = cnt[]
.
return
.
cnt[i] = lower floor (wgt / wgts[i]) floor (vol / vols[i])
while cnt[i] >= 0
knapsack i + 1 val + cnt[i] * vals[i] wgt - cnt[i] * wgts[i] vol - cnt[i] * vols[i]
cnt[i] -= 1
.
.
knapsack 1 0 maxwgt maxvol
for i to n
if best[i] > 0
print best[i] & " " & names$[i]
.
.