You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add knapsack exercise
* Tidy up knapsack exercise
* Move record to test
* Make line ending consistent
Co-authored-by: Victor Goff <[email protected]>
* Revert "Move record to test"
This reverts commit 84a0058.
This is to go back to putting the record in an include file.
* Add comment to include
* Add instructions.append.md
---------
Co-authored-by: Victor Goff <[email protected]>
Your task is to determine which items to take so that the total value of his selection is maximized, taking into account the knapsack's carrying capacity.
4
+
5
+
Items will be represented as a list of items.
6
+
Each item will have a weight and value.
7
+
All values given will be strictly positive.
8
+
Bob can take only one of each item.
9
+
10
+
For example:
11
+
12
+
```text
13
+
Items: [
14
+
{ "weight": 5, "value": 10 },
15
+
{ "weight": 4, "value": 40 },
16
+
{ "weight": 6, "value": 30 },
17
+
{ "weight": 4, "value": 50 }
18
+
]
19
+
20
+
Knapsack Maximum Weight: 10
21
+
```
22
+
23
+
For the above, the first item has weight 5 and value 10, the second item has weight 4 and value 40, and so on.
24
+
In this example, Bob should take the second and fourth item to maximize his value, which, in this case, is 90.
25
+
He cannot get more than 90 as his knapsack has a weight limit of 10.
"blurb": "Given a knapsack that can only carry a certain weight, determine which items to put in the knapsack in order to maximize their combined value.",
0 commit comments