libram 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/diet/knapsack.js +1 -1
- package/package.json +1 -1
package/dist/diet/knapsack.js
CHANGED
|
@@ -53,7 +53,7 @@ export function knapsack(values, capacity) {
|
|
|
53
53
|
if (!Number.isFinite(weight) || weight < 0) {
|
|
54
54
|
throw new Error(`Invalid weight ${weight} for ${thing instanceof Not ? `not ${thing.thing}` : thing}`);
|
|
55
55
|
}
|
|
56
|
-
const maxQuantity = maximum ??
|
|
56
|
+
const maxQuantity = Math.floor(maximum ?? adjustedCapacity / weight);
|
|
57
57
|
if (maxQuantity < 0) {
|
|
58
58
|
throw new Error(`Invalid max quantity ${maxQuantity} for ${thing instanceof Not ? `not ${thing.thing}` : thing}`);
|
|
59
59
|
}
|