in reply to Runs and Sequences
Update: longest value.
#!/usr/local/bin/perl use strict; use warnings; my ($h, $t, $last, $lt, $lh) = (0,0,"T",0,0); while () { my $random = int( rand(2)); if ($random == 0) { print "T $t times. Longest $lt\n" if $t; $lt<$t?$lt=$t:(); $t=0; $h++; } if ($random == 1) { print "H $h times. Longest $lh\n" if $h; $lh<$h?$lh=$h:(); $h=0; $t++; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Runs and Sequences
by twofish (Initiate) on Sep 09, 2005 at 12:22 UTC | |
by thor (Priest) on Sep 09, 2005 at 13:25 UTC |
In Section
Seekers of Perl Wisdom