Skip to content

Commit ed5483f

Browse files
Update knapsack.py
1 parent eded73c commit ed5483f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

knapsack/knapsack.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def knapsack(
2323
>>> val = [60, 100, 120]
2424
>>> w = [10, 20, 30]
2525
>>> c = len(val)
26-
>>> knapsack(cap, w, val, c, False)
26+
>>> knapsack(cap, w, val, c)
2727
220
2828
2929
Given the repetition is NOT allowed,
@@ -46,8 +46,8 @@ def knapsack_recur(capacity: int, counter: int) -> int:
4646
# If weight of the nth item is more than Knapsack of capacity,
4747
# then this item cannot be included in the optimal solution,
4848
# else return the maximum of two cases:
49-
# (1) nth item included one or more times (0-N), if allow_repetition is True
50-
# nth item included only once (0-1), if allow_repetition is False
49+
# (1) nth item included only once (0-1), if allow_repetition is False
50+
# nth item included one or more times (0-N), if allow_repetition is True
5151
# (2) not included
5252
if weights[counter - 1] > capacity:
5353
return knapsack_recur(capacity, counter - 1)

0 commit comments

Comments
 (0)