Knapsack Solver
Solve the knapsack problem with dynamic programming: given items each with a weight and value, and a capacity, pick items to maximize total value without exceeding the capacity. Supports the 0/1 knapsack (each item at most once) and the unbounded knapsack (each item any number of times). The tool reports the optimal value, the selected items, and verifies weight and value. Everything runs locally in your browser.
Items (one per line: name weight value)
Name is a label (optional, defaults to itemN); weight and value are non-negative numbers.
Result
Selected items
The knapsack problem is the archetypal integer optimization: maximize Σ value subject to Σ weight ≤ capacity. The 0/1 variant uses the recurrence dp[i][w] = max(dp[i−1][w], dp[i−1][w−weight_i] + value_i) (each item taken at most once); the unbounded variant uses dp[w] = max over i of (value_i + dp[w−weight_i]) (unlimited copies). Unlike linear programming (which allows fractional items), knapsack variables are integer counts, so the LP relaxation can over-estimate — its optimum is an upper bound on the 0/1 optimum. Pairs with the Linear Programming and Subset-Sum tools. Everything runs locally — nothing leaves your browser.