:school_satchel: @problem-solving/knapsack
© xkcd.com
Knapsack problem algorithms for JavaScript. See docs.
import {
knapsackGreedy,
knapsackApprox,
} from '@problem-solving/knapsack';
knapsackGreedy(n, v, w, W); // 1/2 approximation
knapsackApprox(eps, n, v, w, W); // 1-eps approximation
:book: References
- The knapsack problem explained at Wikipedia.