Re: scramble sentence, how to better program?
by David A. Black other posts by this author
May 8 2008 2:51PM messages near this date
Re: scramble sentence, how to better program?
|
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!
Thread:
Globalrev
David A. Black
S2
S2
Globalrev
S2
7stud --
David A. Black
Rob Biedenharn
S2
S2
|