in reply to Efficient run determination.

Neat problem. Here is my initial crack at it:
use strict; use Data::Dumper; my $string =' aaaa bbbbccccccccbbbb aaaabbbbbcdddddddddddddddd +dddd'; my @bah; my $old_pos = 0; while ($string =~ /((.)\2*)/g) { push @bah, [$2,$old_pos,length($1)]; $old_pos = pos($string); } print Dumper(\@bah);
I am really interested as to how the benchmarking turns out. Let us know.

Update: It is late, but I just realized i would probably benchmark all the code that turns up on this post anyhow. Once again interesting problem.

Updated Again: Changed the \2+ to \2* or it would have failed when there was a series one character long.

-enlil

Replies are listed 'Best First'.
Re: Re: Efficient run determination.
by Enlil (Parson) on Nov 14, 2002 at 11:42 UTC
    Second Try. I am going off to bed after this, my benchmarking tells me this is faster than my previous try:
    use strict; use Data::Dumper; my $string =' aaaa bbbbccccccccbbbb aaaabbbbbcdddddddddddddddd +dddd'; my @bah; while ($string =~ /((.)\2*)/g) { push (@bah, [$2,$-[1],$+[1] - $-[1]]); } print Dumper(\@bah);

    Update Changed the \2+ to \2* or it would have failed when there was a series one character long.

    -enlil