Skip to content

Commit 5d6fed9

Browse files
Sync the knapsack exercise's docs with the latest data. (exercism#187)
1 parent 731a45b commit 5d6fed9

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,25 @@
11
# Instructions
22

3-
In this exercise, let's try to solve a classic problem.
3+
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.
44

5-
Bob is a thief.
6-
After months of careful planning, he finally manages to crack the security systems of a high-class apartment.
7-
8-
In front of him are many items, each with a value (v) and weight (w).
9-
Bob, of course, wants to maximize the total value he can get; he would gladly take all of the items if he could.
10-
However, to his horror, he realizes that the knapsack he carries with him can only hold so much weight (W).
11-
12-
Given a knapsack with a specific carrying capacity (W), help Bob determine the maximum value he can get from the items in the house.
13-
Note that Bob can take only one of each item.
14-
15-
All values given will be strictly positive.
165
Items will be represented as a list of items.
176
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.
189

1910
For example:
2011

21-
```none
12+
```text
2213
Items: [
2314
{ "weight": 5, "value": 10 },
2415
{ "weight": 4, "value": 40 },
2516
{ "weight": 6, "value": 30 },
2617
{ "weight": 4, "value": 50 }
2718
]
2819
29-
Knapsack Limit: 10
20+
Knapsack Maximum Weight: 10
3021
```
3122

3223
For the above, the first item has weight 5 and value 10, the second item has weight 4 and value 40, and so on.
33-
3424
In this example, Bob should take the second and fourth item to maximize his value, which, in this case, is 90.
3525
He cannot get more than 90 as his knapsack has a weight limit of 10.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Introduction
2+
3+
Bob is a thief.
4+
After months of careful planning, he finally manages to crack the security systems of a fancy store.
5+
6+
In front of him are many items, each with a value and weight.
7+
Bob would gladly take all of the items, but his knapsack can only hold so much weight.
8+
Bob has to carefully consider which items to take so that the total value of his selection is maximized.

0 commit comments

Comments
 (0)