Merge pull request #330 from bharath-123/patch-1

Added test case to knapsack.py
This commit is contained in:
Christian Bender 2018-07-23 00:07:27 +02:00 committed by GitHub
commit 6da7becf5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,3 +12,13 @@ def knapsack(W, wt, val, n):
dp[i][w] = dp[i-1][w]
return dp[n][w]
if __name__ == "__main__":
val = [3,2,4,4]
wt = [4,3,2,3]
W = 6
n = 4
'''
Should give 8
'''
print(knapsack(W,wt,val,n))