brewersfan1976

knapsacklight2.rb

Feb 23rd, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.51 KB | None | 0 0
  1. def knapsackLight2(weight1, weight2, maxW)
  2.     if weight1 + weight2 <= maxW then
  3.         return "both"
  4.     end
  5.        
  6.     if weight1 + weight2 > maxW and weight1 <= maxW and weight2 <= maxW then
  7.         return "either"
  8.     end
  9.            
  10.     if weight1 > maxW and weight2 > maxW then
  11.        return "none"
  12.     end
  13.              
  14.     if weight1 <= maxW and weight2 > maxW then
  15.        return "first"
  16.     end
  17.            
  18.     if weight2 <= maxW and weight1 > maxW then
  19.        return "second"
  20.     end
  21. end
Advertisement
Add Comment
Please, Sign In to add comment