(Names are just examples, they don't need to be named like this)
GrandTotal- integer to divide
SplitCount- number of output integers required
UpperLimit- highest valid value for any one output integer
LowerLimit- lowest valid value for any one output integer
Outout must be a random set of
SplitCount integers, each between
LowerLimit (your language's RNG is fine), the sum of which is
The output should be uniformly random in that any valid output should be equally likely. For example input of [8,3,4,2] has the following six valid outputs:
Each output should have, therefore, 1/6 chance of occurring.
The order of the output matters: 5,8,7 is not an equal set to 5,7,8. Both outputs must be equally likely if either is possible.
(This does mean that output where all three integers are the same is less likely output to one where all three are different: Given
LowerLimit=1, a set including 1, 2 and 3 can appear in 6 different configurations, while a set of all 2s can only appear in one, making it 6 times as likely that one of the varied sets will appear, rather than the set of 3 2s.)
Any input variables should work, assuming that the following is true
- all input variables are positive integers.
Submissions that accept invalid input but return output as though it was the closest valid input would win a tie-breaker. (eg
LowerLimit=2 returning [5,5] treats the
UpperLimit variable as though it was the lowest valid input, rather than what it was.) Closest here means change as few variables as possible, and change those variables by the smallest possible integer. Ideally, change the latest possible variable(s) (here,
SplitCount could have been changed to make input valid, but
UpperLimit is a later variable.)
Sample in-out range
|GrandTotal||SplitCount||UpperLimit||LowerLimit||Possible Output Range|