DivideInto Parameters

Top  Previous  Next

DivideInto parameters divide a given number of objects into a given number of groups. It is useful if you want to generate (for example) three random numbers which ALWAYS add up to 30. This particular job is quite difficult to do without the divideinto parameter.

 

$p=divideinto(total,number of groups)

 

Example:

 

$p=divideinto(100,4)                Divides 100 into four groups. This might result in the values 22,31,15,32  or  10,31,5,54

 

In this example, the four results will always add up to 100

 

Individual elements of $p are accessed using references - $p[1], $p[2], $p[3] and $p[4].