We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 72b3adf commit eded73cCopy full SHA for eded73c
knapsack/knapsack.py
@@ -54,7 +54,7 @@ def knapsack_recur(capacity: int, counter: int) -> int:
54
else:
55
left_capacity = capacity - weights[counter - 1]
56
new_value_included = values[counter - 1] + knapsack_recur(
57
- left_capacity, not allow_repetition ? counter - 1 : counter
+ left_capacity, counter - 1 if not allow_repetition else counter
58
)
59
without_new_value = knapsack_recur(capacity, counter - 1)
60
return max(new_value_included, without_new_value)
0 commit comments