From: Rick DeNatale Date: 2008-02-28T07:21:31+09:00 Subject: Re: Math problem On 2/27/08, Pit Capitain wrote: > 2008/2/27, Rick DeNatale : > > > Not exactly the fastest way to do it empirically, why random. > > > (...) > > Rick, are you sure? > Well except in the case where some ZERO cleverly seeds the random number generator to produce the right random numbers, yes! A very slight modification: def init_counts zero = 0 @counts = Hash.new(zero) end produces: father: 48 daughter: 12 Father is 48 years old, Daughter is 12. rick: 12 loops thomas: 19467 loops Of course, being random, the thomas count varies, while the rick count stays at 12. And then I much prefer the algebraic solution I worked out in a few seconds on paper when the question was first posed. I leave to others the pleasure of discovering the details of your trick. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/