Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def knapsackLight2(weight1, weight2, maxW)
- if weight1 + weight2 <= maxW then
- return "both"
- end
- if weight1 + weight2 > maxW and weight1 <= maxW and weight2 <= maxW then
- return "either"
- end
- if weight1 > maxW and weight2 > maxW then
- return "none"
- end
- if weight1 <= maxW and weight2 > maxW then
- return "first"
- end
- if weight2 <= maxW and weight1 > maxW then
- return "second"
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment