Skip to content

Commit 6da7bec

Browse files
author
Christian Bender
authored
Merge pull request #330 from bharath-123/patch-1
Added test case to knapsack.py
2 parents 9faaebc + d96048a commit 6da7bec

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Diff for: dynamic_programming/knapsack.py

+10
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,13 @@ def knapsack(W, wt, val, n):
1212
dp[i][w] = dp[i-1][w]
1313

1414
return dp[n][w]
15+
if __name__ == "__main__":
16+
val = [3,2,4,4]
17+
wt = [4,3,2,3]
18+
W = 6
19+
n = 4
20+
'''
21+
Should give 8
22+
'''
23+
print(knapsack(W,wt,val,n))
24+

0 commit comments

Comments
 (0)