http://qs321.pair.com?node_id=458506

Stenyj has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I'm attempting to script a program that will allow me to evaluate something, based on the % of which each element makes up of the item.

Summary:
- 5 items
- Each item will have a %, and the total % of all 5 items together must equal 100%
- How can I estbalish a script to fill a table in a DB with every single possible outcome? The table would have 5 columns (one of each item) and the rows would simply have the % that each item was assigned (which would total 100 for each row)

NOTE: I'd ideally like to be able to chose to only allow increments of 2 or 5, to reduce the amount of outcomes (and thus, reduce the amount of time it would take the produce & record all possible outcomes).
So instead of:
100 0 0 0 0
99 1 0 0 0
98 2 0 0 0
etc. (and on and on and on)

I could specify it to do:
100 0 0 0 0
98 2 0 0 0
96 4 0 0 0
etc.

which would dramatically reduce the number of possibilities.

Any advice/suggestions etc. on how to approach this would be GREATLY appreciated.

I've started experimenting with tryign to figure out way to do this with nested loops, but am running into problems & I'm sure there must be a more efficient way.


Thank you for any feedback you may be able to provide!

Regards,
Stenyj