tedd wrote: > > Alain: > > >'set initial values ordered from 1 to 49 > > FOR i = 1 TO 49 > > gValue%(i) = i > > NEXT > > 'set last item to a random number (1-49) > > gValue%(50) = RND(49) > > 'shuffle the array > > FOR i = 1 TO 50 > > SWAP gValue%(i), gValue%(RND(50)) > > NEXT > > Why not: > > FOR i = 1 TO 50 > gValue%(i) = i > NEXT > FOR i = 1 TO 50 > SWAP gValue%(i), gValue%(RND(50)) > NEXT > Why not? Because from what I have understood, the problem Jeffrey was having was with the 50th item (must be a number between 1 and 49 and also it must be in a random location). I'm not sure I have fully understood the question though. > However, the RND(50) function means that it is returning a number "at > random" between 0 and 51 (x>0 AND x<51). It may return, and most > probably will return, the same number more than once in 50 calls. As > such, then the values of some indexes will be moved to other indexes > while others aren't moved at all (rather moved to themselves). It's > an interesting solution and was not obvious to me. > OK, but when a value is not moved, say when index = 1 and the RND function returns 1, this doesn't stop the value at index 1 to be moved later, say when index = 6 and RND(50) returns 1 again. Ingenious, no? -- Cheers Alain ----------------------------------------------------- FB^3 in Europe: http://euro.futurebasic.com/ FB II Pouch: http://www.pixmix.com/FB/outils.html -----------------------------------------------------