On Tue, Feb 28, 2012 at 7:10 PM, John Merlino <stoici...@aol.com> wrote: > Hey all, using ruby 1.8.7, I wrote this: > > 500.times.map { Integer((rand * 1) * 1000) / Float(1000) } > > Basically, this gives me a list of 500 random decimal numbers that are > rounded to 3 places. However, I also want to make sure that all are > unique. > > thanks for response > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >
Here is one thing that comes to mind a = (1..1000).to_a a.shuffle! pick 1st 500 a[0,500] last 500 item from the list a[-500..-1] If you want you can call shuffle a few times, see what works best for you. -- Kind Regards, Rajinder Yadav SafetyNet Test Driven Development http://safetynet.devmentor.org -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.