You go to store, where each product has price. Prices are in vector
s = [ 195 125 260 440 395 290]
and you have amount of money n=570
Question is what can you buy, if you want to use whole amount of money
For this data answer is
y=[ 125 125 125 195]
With other data it can be more than one solution.
Solution Stats
Problem Comments
3 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers94
Suggested Problems
-
Project Euler: Problem 6, Natural numbers, squares and sums.
2536 Solvers
-
430 Solvers
-
Who is the smartest MATLAB programmer?
789 Solvers
-
Count consecutive 0's in between values of 1
516 Solvers
-
Return fibonacci sequence do not use loop and condition
851 Solvers
More from this Author12
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Please add more than one test case. Otherwise, the problem can be obviated by simply hard-coding solutions. You mention that with some data sets there could be more than one solution. Well, please put in the time and effort to develop a suitable test suite with such test cases included. Three or four test cases should be a minimum.
A good problem, but it desperately needs more test cases. Sadly, intlinprog is not an acceptable solution method.
This is a nice problem, I encourage you to extend it with additional test cases. Also it is unclear what format you would expect the output to be when there are multiple solutions: multiple outputs? a cell array?