16 lines
334 B
Perl
16 lines
334 B
Perl
use strict;
|
|
use warnings;
|
|
use feature 'bitwise';
|
|
|
|
print "lcs is ", lcs('thisisatest', 'testing123testing'), "\n";
|
|
|
|
sub lcs
|
|
{
|
|
my ($c, $d) = @_;
|
|
for my $len ( reverse 1 .. length($c &. $d) )
|
|
{
|
|
"$c\n$d" =~ join '.*', ('(.)') x $len, "\n", map "\\$_", 1 .. $len and
|
|
return join '', @{^CAPTURE};
|
|
}
|
|
return '';
|
|
}
|