Read item weights and values for a tiny knapsack. This is a small deterministic example, not solver engineering.

Example

Read item weights and values for a tiny knapsack. The knapsack problem asks which items to pack to maximize total value without exceeding a weight limit. Laying out each item's weight and value side by side sets up that tension: heavier items may be worth more, so the best choice balances value gained against the capacity it consumes.

highlighted = computed this step

Step 1 — Capacity

Set up the exact small combinatorics values.

capacity7\begin{array}{c|c}\text{capacity}&\text{7}\end{array}

Step 2 — Items

Compute the highlighted combinatorics value.

item, weight, value((A, 2, 6), (B, 3, 7), (C, 4, 10), (D, 5, 12))\begin{array}{c|c}\text{item, weight, value}&\hlmath{\text{((A, 2, 6), (B, 3, 7), (C, 4, 10), (D, 5, 12))}}\end{array}
combinatorics-search Every row is intentionally ordered and pinned to the lesson specification.