PDA

View Full Version : code for all possible cases



alyalko
08-28-2007, 05:13 AM
I'm looking to code all possible cases of weighting 5 variables by 20% increments. here is an example

1 2 3 4 5
100 0 0 0 0
80 20 0 0 0
80 0 20 0 0
80 0 0 20 0
80 0 0 0 20
60 40 0 0 0
60 0 40 0 0
60 0 0 40 0
60 0 0 0 40
60 20 20 0 0
60 20 0 20 0
60 20 0 0 20
and so on...

anyone have a good idea as to how to code this?

austenr
08-28-2007, 06:02 AM
This looks kind of like a homework problem. That is probably why no one has answered your question. That and the fact that we generally like to see a sample workbook. It makes everyones job much easier. Please post one after de sensitizing it of course.

alyalko
08-28-2007, 08:17 AM
nevermind, i did it the hard way. just nested the amount of loops as variables and ran them from 0 to 1 by % allocation then just did a check for the sum to equal 1 and only passed through the ones that met that constraint.

unmarkedhelicopter
08-28-2007, 08:39 AM
That's funny cos it's probably the way we'd have solved it for you :)