[kw-pm] Free beer: still unclaimed!

Simon Law sfllaw at law.yi.org
Thu Nov 18 03:40:00 CST 2004


On Thu, Nov 18, 2004 at 12:25:03AM -0500, Eric - fishbot wrote:
> 
> > I daebetd and daebted wehethr I tuhhogt tihs was a cool
> > egonuh use of map...  and I tnihk I'll let you dcdiee. :)
> >
> > perl -pe 's/\B(\w+)\B/join"",map chop,sort map{rand().$_}split"",$1/eg'
> 
> What amazes me most about this is not so much the code but the
> fact that it is pretty fast.  I ran this over my entire kw-pm
> mailbox (16,000 lines of text) and it took 4 seconds. Considering
> a random number is generated for every internal letter... that's
> amazing to me.  It did my 230,000 word dictionary in 24 seconds.

This is because srand() is only called once by rand().  After that,
rand() is a pseudo-random number, which of course, can be generated
quite quickly.

Simon


More information about the kw-pm mailing list