I'm sorry. I looked at the code, but I do not see anything there that suggests that it can achieve the impossible.

Firstly, neither of the routines in the linked post seem to work?

#! perl -slw use strict; sub lcs_arrays1 { my ( $a1, $a2 ) = @_; my @matches; my $longest = 0; my @last; my @this; for my $b1 ( 0 .. $#$a1 ) { @this = @last; @last = (); for my $b2 ( 0 .. $#$a2 ) { if ( $$a1[$b1] eq $$a2[$b2] ) { my @match = ( $$a1[$b1] ); my $e2 = $b2+1; $this[$e2] = $last[$e2-1] + 1; if ($this[$e2] > $longest) { $longest = $this[$e2]; @matches = (); } if ($this[$e2] == $longest) { push @matches, [ @{$a1}[ ($b1-$longest+1), $b1 ] ]; } } } } return $matches[0]; # array ref -> longest matching list } sub lcs_arrays2 { my ( $a1, $a2 ) = @_; my @match; my $longest = 0; my @last; my @this; for my $b1 ( 0 .. $#$a1 ) { @this = @last; @last = (); for my $b2 ( 0 .. $#$a2 ) { if ( $$a1[$b1] eq $$a2[$b2] ) { my @match = ( $$a1[$b1] ); my $e2 = $b2+1; $this[$e2] = $last[$e2-1] + 1; if ($this[$e2] > $longest) { $longest = $this[$e2]; @match = @{$a1}[ ($b1-$longest+1), $b1 ]; } } } } return \@match; # array ref -> longest matching list } my @a = ( 'a'..'d' ); my @b = ( 'b'..'d' ); print 'v1: ', @{ lcs_arrays1( \@a, \@b ) }; print 'v2: ', @{ lcs_arrays2( \@a, \@b ) }; __END__ C:\test\690326>ikegami.pl Use of uninitialized value in addition (+) at C:\test\690326\ikegami.p +l line 20. Use of uninitialized value in addition (+) at C:\test\690326\ikegami.p +l line 20. Use of uninitialized value in addition (+) at C:\test\690326\ikegami.p +l line 20. v1: bb Use of uninitialized value in addition (+) at C:\test\690326\ikegami.p +l line 55. Use of uninitialized value in addition (+) at C:\test\690326\ikegami.p +l line 55. Use of uninitialized value in addition (+) at C:\test\690326\ikegami.p +l line 55. v2:

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re^5: LCS efficiency problem by BrowserUk
in thread LCS efficiency problem by zhe

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.