From: Benoit Daloze Date: 2010-06-21T20:13:16+09:00 Subject: Re: [QUIZ] Random Points within a Circle (#234) Hi ! On 19 June 2010 20:05, Daniel Moore wrote: > ## 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 So here is my solution in a hundred lines, with an ImageMagick visualisation: http://gist.github.com/446707 I had an intuition doing some Math.sqrt about the distance, and it revealed to be exact :) Enjoy, Benoit Daloze