0/1 Knapsack (DP)
Find the highest-value subset within a capacity and inspect its dynamic-programming table.
About this tool
Choose items to maximize total value without exceeding the capacity. Every line represents one distinct item, usable at most once. Enter weight,value separated by a comma, semicolon or space. Blank lines and lines beginning with # are ignored.
Weights and capacity use the same arbitrary unit. This learning tool accepts capacity and weights 0–40, up to 12 items and whole nonnegative values up to 1000000. Zero-weight items are allowed; equal items are distinct copies.
The DP table shows the best value using the first i items at capacity c. Each cell compares skipping item i with taking it plus the previous row at c−weight. The highlighted path traces the selected set; tied solutions keep the earlier selection. It does not promise minimum weight or all optimal sets.
Calculation is immediate and uses O(n × (capacity + 1)) time and memory for n items. Editing clears old results; Reset restores the example. Raw inputs and comments are saved locally in this browser, including unfinished capacity entries. Recalculate after reloading. Older saved or shared examples remain supported. A draft exceeding the local saving limit shows a warning: copy the text before leaving. The previous saved copy is retained.