[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Perl Card Games




Chip Turner wrote:
> 
> @cards = (0 .. 51);
> $passes = 1;
> $cards[$_ % @cards] = $cards[rand(@cards) % @cards]
> 	foreach 0 .. ($passes * @cards - 1);

I can save you a few bytes:
	
$cards[$_] = $cards[rand(@cards)]
	foreach ((0 .. $#cards) x $passes);

(And of course this also applies to the bug fix, mentioned by others.)

John Porter


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe