in reply to Re^2: Runs and Sequences
in thread Runs and Sequences

Well ... I could be wrong (I'm no perl guru) but .. why not first cut up the string into H's and T's, place them into an array. Now create a flag $H=0 as an example and then create a simple for loop, where you go though the array and create the appropriate if else statements to get the info you need.
Make sense?

Replies are listed 'Best First'.
Re^4: Runs and Sequences
by twofish (Initiate) on Sep 09, 2005 at 11:58 UTC
    Hrm, I'll try to wrap my head around that, cutting them up and where to is kind of the issue. I was hoping to do something like:
    my $last; my $count; my $toss = headsortails(); # returns either 0 or 1 (H or T) if ($toss == $last) { $count++; } else { $last = $toss; $c{$count}++; } if you had a bunch of variables like $c1, $c2
    Thought the implementation didn't really work out.