From: "David A. Black" Date: 2008-05-09T06:51:24+09:00 Subject: Re: scramble sentence, how to better program? Hi -- On Fri, 9 May 2008, S2 wrote: > David A. Black wrote: > >> print "Enter a sentence: " >> puts gets.split.sort_by { rand }.join(" ") > > but does this take into account that rand could generate the same numer two > times? while that is not likely, it could happen. I'm by no means a random number expert/theorist, but the above is a very common idiom. I don't really know how it holds up under full scrutiny. There's probably some discussion of that in the archives. David -- Rails training from David A. Black and Ruby Power and Light: INTRO TO RAILS June 9-12 Berlin ADVANCING WITH RAILS June 16-19 Berlin INTRO TO RAILS June 24-27 London (Skills Matter) See http://www.rubypal.com for details and updates!