Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def knapsackLight(value1, weight1, value2, weight2, maxW)
- if weight1 + weight2 <= maxW then
- return value1 + value2
- end
- if value1 > value2 and weight1 <= maxW then
- return value1
- end
- if value2 > value1 and weight2 <= maxW then
- return value2
- end
- if value1 < value2 and weight1 <= maxW then
- return value1
- end
- if value1 == value2 then
- return value1
- end
- return 0
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement