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

In reply to How to determine & record all possible variations for 5 items? by Stenyj

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.