in reply to Block Search

I think I'd do it something .like this. If you want all of the blocks they are in @segs.

#!/usr/bin/perl use strict; use warnings; my $string = 'abbbcddddfegrgrgddeeeeedd'; # Get repeated characters my @segs = $string =~ /((.)\2+)/g; # Filter to get only multi-char strings @segs = grep { length > 1 } @segs; # Sort @segs = sort { length $b <=> length $a } @segs; # Construct answer string my $answer = '-' x index($string, $segs[0]) . $segs[0]; $answer .= '-' x (length($string) - length($answer)); print "$string\n$answer\n";
--
<http://www.dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re: Re: Block Search
by artist (Parson) on Oct 04, 2002 at 17:07 UTC
    Yep,
    That is much cleaner and more informative solution.
    Getting all the blocks is nice.
    Now How I would go about 2-D and 3-D.

    Thanks,
    Extracting the visual art
    an artist.

      As far as I understand expanding this to 2 and 3 dimensions is non trivial. Consider that video compression techniques perform this type of task. They try to find as large areas of similar color as possible. So you probably want to look into algortihms used for that. Also look in a book that has a lot of algorithm coverage of pattern matching. If the number of symbols is low then I believe there are a few useful techniques that are reasonably understandable. But unfortunately the book im thinking of isnt here. Sorry.

      --- demerphq
      my friends call me, usually because I'm late....