Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

prog challenge

Name: Anonymous 2010-09-13 8:38

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: Anonymous 2010-09-13 9:07

span = 2 * (max - average)
min = max - span
[min + rand(span) for _ in length]


sewdo-code

Name: Anonymous 2010-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

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List