From: Shawn Anderson Date: 2008-03-25T10:09:18+09:00 Subject: Re: generating unique random numbers ------=_Part_15268_22006047.1206407346534 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline ar = [] while ar.length < 8 ar << rand(12) + 1 ar.uniq! end /Shawn On Mon, Mar 24, 2008 at 6:00 PM, Jimmy Palmer wrote: > I'm trying to generate 8 unique random numbers between 1 and 13. > > for example my first set of results could be: > > 2, 8, 4, 6, 3, 10, 12, 1 > > the results need to be between 1 and 13 and they must be unique. > > The rand(12) + 1 returns random numbers between 1 and 13, but they are > not unique. Any quick solutions? > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_15268_22006047.1206407346534--