permutations of 4 numbers in 7 positions IF the sum of the numbers is 600
3 views (last 30 days)
Show older comments
I want to generate all permutations of 4 numbers in 7 places, but we have a condition that the sum of the 7 places should be 600.
my nambers are 100,125,75,50
It is clear that repetition is allowed.
How can i do that?
1 Comment
Answers (2)
the cyclist
on 11 May 2022
This is a "making change" problem, where the smaller numbers can represent coins, and the large number is the total of the change. You can use the makeChange function from the File Exchange to do this.
Below, I've generate all possible combinations. It wasn't clear to me if you need up to 7 numbers, or exactly 7 numbers, but you should be able to trim the list accordingly.
[count, combos] = makeChange(600,[125,100,75,50])
0 Comments
See Also
Categories
Find more on Shifting and Sorting Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!