From: Yaser Sulaiman Date: 2010-06-22T07:30:37+09:00 Subject: Re: [QUIZ] Random Points within a Circle (#234) --001636b2b0e8561a0c048991da68 Content-Type: text/plain; charset=ISO-8859-1 It's not as advanced as Daloze's solution, and it definitely can (should?) be enhanced, but my solution is available at http://gist.github.com/447554. Any feedback is welcomed. In a nutshell, Point.random implements a random algorithm that basically repositions the head of an initial null vector v until it falls within a circle of the given radius that is centered around the origin. It then translates a copy of that head to the correct position with respect to the given center. BTW, this is the first time I participate in the Ruby Quiz. I'm looking forward to future quizzes :) Regards, Yaser Sulaiman On Sat, Jun 19, 2010 at 9:05 PM, Daniel Moore wrote: > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- > > The three rules of Ruby Quiz: > > 1. Please do not post any solutions or spoiler discussion for this > quiz until 48 hours have elapsed from the time this message was > sent. > > 2. Support Ruby Quiz by submitting ideas and responses > as often as you can. > > 3. Enjoy! > > Suggestion: A [QUIZ] in the subject of emails about the problem > helps everyone on Ruby Talk follow the discussion. Please reply to > the original quiz message, if you can. > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > > RSS Feed: http://rubyquiz.strd6.com/quizzes.rss > > Suggestions?: http://rubyquiz.strd6.com/suggestions > > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- > > ## Random Points within a Circle (#234) > > Greetings Rubyists, > > Generating random numbers is a useful feature and Ruby provides us > with `Kernel.rand` to generate numbers uniformly distributed between > zero and one. If we want to generate random numbers with other > distributions, then we'll need to do a little work. The quiz this week > is to generate random points uniformly distributed within a circle of > a given radius and position. > > This quiz is relatively simple, great if you are new to Ruby or > strapped for time. Remember, it is contributions from people like > *you* that make Ruby Quiz succeed! > > Have fun! > > -- > -Daniel > http://rubyquiz.strd6.com > > --001636b2b0e8561a0c048991da68--