Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,62 +0,0 @@
|
|||
function lcs([String]$a, [String]$b)
|
||||
{
|
||||
if ([String]::IsNullOrEmpty($a) -or [String]::IsNullOrEmpty($b))
|
||||
{
|
||||
return ""
|
||||
}
|
||||
$startIndex, $size = -1, -1
|
||||
for ($k = 0; $k -lt $a.Length; ++$k)
|
||||
{
|
||||
for ($i, $j, $d = $k, 0, 0; ($i -lt $a.Length) -and ($j -lt $b.Length); ++$i, ++$j)
|
||||
{
|
||||
if ($a.Chars($i) -eq $b.Chars($j))
|
||||
{
|
||||
$d += 1
|
||||
if ($size -lt $d)
|
||||
{
|
||||
$startIndex = $i - $d + 1
|
||||
$size = $d
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$d = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
for ($k = 1; $k -lt $b.Length; ++$k)
|
||||
{
|
||||
for ($i, $j, $d = 0, $k, 0; ($i -lt $a.Length) -and ($j -lt $b.Length); ++$i, ++$j)
|
||||
{
|
||||
if ($a.Chars($i) -eq $b.Chars($j))
|
||||
{
|
||||
$d += 1
|
||||
if ($size -lt $d)
|
||||
{
|
||||
$startIndex = $i - $d + 1
|
||||
$size = $d
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$d = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($size -lt 0)
|
||||
{
|
||||
return ""
|
||||
}
|
||||
return $a.Substring($startIndex, $size)
|
||||
}
|
||||
|
||||
function Print-Lcs([String]$a, [String]$b)
|
||||
{
|
||||
return "lcs $a $b = $(lcs $a $b)"
|
||||
}
|
||||
Print-Lcs 'thisisatest' 'testing123testing'
|
||||
Print-Lcs 'testing' 'sting'
|
||||
Print-Lcs 'thisisatest_stinger' 'testing123testingthing'
|
||||
Print-Lcs 'thisisatest_stinger' 'thisis'
|
||||
Print-Lcs 'testing123testingthing' 'thisis'
|
||||
Print-Lcs 'thisisatest' 'thisisatest'
|
||||
Loading…
Add table
Add a link
Reference in a new issue