-
-
Notifications
You must be signed in to change notification settings - Fork 46.6k
Implementation of the Knapsack Problem Solver #11401 #11406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding few of these?
"""
>>> capacity = 50
>>> values = [60, 100, 120]
>>> weights = [10, 20, 30]
>>> knapsack_dp(capacity, weights, values)
220
>>> capacity = 0
>>> values = [60, 100, 120]
>>> weights = [10, 20, 30]
>>> knapsack_dp(capacity, weights, values)
0
>>> capacity = 10
>>> values = [10, 10, 10]
>>> weights = [5, 5, 5]
>>> knapsack_dp(capacity, weights, values)
20
>>> capacity = 100
>>> values = [60, 100, 120, 80, 30]
>>> weights = [10, 20, 30, 40, 50]
>>> knapsack_dp(capacity, weights, values)
300
>>> capacity = 7
>>> values = [1, 4, 5, 7]
>>> weights = [1, 3, 4, 5]
>>> knapsack_dp(capacity, weights, values)
9
"""
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Until that looks fine!!
sure I'll do that as well |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented the changes asked as well
Here the docstring has an incorrect case.
|
We already have an implementation of the DP solution to the 0-1 knapsack problem in |
Describe your change:
Fixes #11401
Checklist: