permutations of 4 numbers in 7 positions IF the sum of the numbers is 600
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Réponses (2)
the cyclist
le 11 Mai 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 commentaires
Voir également
Catégories
En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!