Create a sequence of random integers with the following given: max, average, length
Example, with m = 7, a = 4, l = 5, you get [ 5, 2, 2, 4, 7 ].
Name:
Anonymous2010-09-13 9:07
span = 2 * (max - average)
min = max - span
[min + rand(span) for _ in length]
sewdo-code
Name:
Anonymous2010-09-13 9:20
>>4
Try it, won't work. Assuming rand(span) returns anything from 0 to span, it's possible that all rand's return 0.
Therefore your sequence is made of min's only and its average is min and not average, but min is equal max - 2average, so they're not necessarily equal