From: Jason Williams Date: 2003-09-16T23:51:29+09:00 Subject: Re: scrambler one-liner In article <200309161631.48824.fxn@hashref.com>, Xavier Noria wrote: > -pe 'gsub!(/\w+/){|w|r=1..w.size-1;w[r]=w[r].split(//).sort_by{rand}.to_s;w}' > > The cool Array.sort_by { rand } trick is a shuffle I saw in Freenode#ruby-lang > last week, I would like very much to remember the nick of who showed it but I > can't remember. > > It seems one-liners are not at the heart of the Ruby community, but hey, > that's funny in the end. Can you shorten it? Alternatively, you could write a version that accepts a "Maximum distance" for letters to be moved from their original position. Most people notice after playing for a short while that it doesn't work so well for longer words; I'm curious whether it's actually a limit of "total shuffle distance".