in reply to Re: Send x% of the users to A, the rest to B
in thread Send x% of the users to A, the rest to B
Cool snippet! Interesting to see that (at least on my Debian box) it takes a few dozen iterations to actually reach middle ground:
perl -Mstrict -Mwarnings -E 'my $WIDTH = 50; my ( $try, $i, $j ) = (0) x 3; for ( 1 .. 40 ) { ++$try; my $rand = `perl -E "say rand()"`; $rand < .5 ? ++$i : ++$j; printf qq[%${WIDTH}s : %s\n], "#" x ( $i * $WIDTH / $try ), "#" x ( $j * $WIDTH / $try ); }'
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Send x% of the users to A, the rest to B
by BrowserUk (Patriarch) on Oct 27, 2012 at 21:02 UTC |
In Section
Seekers of Perl Wisdom