Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,14 @@
|
|||
sub lcs {
|
||||
my ($a, $b) = @_;
|
||||
if (!length($a) || !length($b)) {
|
||||
return "";
|
||||
}
|
||||
if (substr($a, 0, 1) eq substr($b, 0, 1)) {
|
||||
return substr($a, 0, 1) . lcs(substr($a, 1), substr($b, 1));
|
||||
}
|
||||
my $c = lcs(substr($a, 1), $b) || "";
|
||||
my $d = lcs($a, substr($b, 1)) || "";
|
||||
return length($c) > length($d) ? $c : $d;
|
||||
}
|
||||
|
||||
print lcs("thisisatest", "testing123testing") . "\n";
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
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 '';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue