Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -0,0 +1,25 @@
|
|||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
|
||||
procedure Test_LCS is
|
||||
function LCS (A, B : String) return String is
|
||||
begin
|
||||
if A'Length = 0 or else B'Length = 0 then
|
||||
return "";
|
||||
elsif A (A'Last) = B (B'Last) then
|
||||
return LCS (A (A'First..A'Last - 1), B (B'First..B'Last - 1)) & A (A'Last);
|
||||
else
|
||||
declare
|
||||
X : String renames LCS (A, B (B'First..B'Last - 1));
|
||||
Y : String renames LCS (A (A'First..A'Last - 1), B);
|
||||
begin
|
||||
if X'Length > Y'Length then
|
||||
return X;
|
||||
else
|
||||
return Y;
|
||||
end if;
|
||||
end;
|
||||
end if;
|
||||
end LCS;
|
||||
begin
|
||||
Put_Line (LCS ("thisisatest", "testing123testing"));
|
||||
end Test_LCS;
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
|
||||
procedure Test_LCS is
|
||||
function LCS (A, B : String) return String is
|
||||
L : array (A'First..A'Last + 1, B'First..B'Last + 1) of Natural;
|
||||
begin
|
||||
for I in L'Range (1) loop
|
||||
L (I, B'First) := 0;
|
||||
end loop;
|
||||
for J in L'Range (2) loop
|
||||
L (A'First, J) := 0;
|
||||
end loop;
|
||||
for I in A'Range loop
|
||||
for J in B'Range loop
|
||||
if A (I) = B (J) then
|
||||
L (I + 1, J + 1) := L (I, J) + 1;
|
||||
else
|
||||
L (I + 1, J + 1) := Natural'Max (L (I + 1, J), L (I, J + 1));
|
||||
end if;
|
||||
end loop;
|
||||
end loop;
|
||||
declare
|
||||
I : Integer := L'Last (1);
|
||||
J : Integer := L'Last (2);
|
||||
R : String (1..Integer'Max (A'Length, B'Length));
|
||||
K : Integer := R'Last;
|
||||
begin
|
||||
while I > L'First (1) and then J > L'First (2) loop
|
||||
if L (I, J) = L (I - 1, J) then
|
||||
I := I - 1;
|
||||
elsif L (I, J) = L (I, J - 1) then
|
||||
J := J - 1;
|
||||
else
|
||||
I := I - 1;
|
||||
J := J - 1;
|
||||
R (K) := A (I);
|
||||
K := K - 1;
|
||||
end if;
|
||||
end loop;
|
||||
return R (K + 1..R'Last);
|
||||
end;
|
||||
end LCS;
|
||||
begin
|
||||
Put_Line (LCS ("thisisatest", "testing123testing"));
|
||||
end Test_LCS;
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
function Get-Lcs ($ReferenceObject, $DifferenceObject)
|
||||
{
|
||||
$longestCommonSubsequence = @()
|
||||
$x = $ReferenceObject.Length
|
||||
$y = $DifferenceObject.Length
|
||||
|
||||
$lengths = New-Object -TypeName 'System.Object[,]' -ArgumentList ($x + 1), ($y + 1)
|
||||
|
||||
for($i = 0; $i -lt $x; $i++)
|
||||
{
|
||||
for ($j = 0; $j -lt $y; $j++)
|
||||
{
|
||||
if ($ReferenceObject[$i] -ceq $DifferenceObject[$j])
|
||||
{
|
||||
$lengths[($i+1),($j+1)] = $lengths[$i,$j] + 1
|
||||
}
|
||||
else
|
||||
{
|
||||
$lengths[($i+1),($j+1)] = [Math]::Max(($lengths[($i+1),$j]),($lengths[$i,($j+1)]))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (($x -ne 0) -and ($y -ne 0))
|
||||
{
|
||||
if ( $lengths[$x,$y] -eq $lengths[($x-1),$y])
|
||||
{
|
||||
--$x
|
||||
}
|
||||
elseif ($lengths[$x,$y] -eq $lengths[$x,($y-1)])
|
||||
{
|
||||
--$y
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($ReferenceObject[($x-1)] -ceq $DifferenceObject[($y-1)])
|
||||
{
|
||||
$longestCommonSubsequence = ,($ReferenceObject[($x-1)]) + $longestCommonSubsequence
|
||||
}
|
||||
|
||||
--$x
|
||||
--$y
|
||||
}
|
||||
}
|
||||
|
||||
$longestCommonSubsequence
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
(Get-Lcs -ReferenceObject "thisisatest" -DifferenceObject "testing123testing") -join ""
|
||||
|
|
@ -0,0 +1 @@
|
|||
Get-Lcs -ReferenceObject @(1,2,3,4) -DifferenceObject @(1,2,2,4,5,3,3,3,2,4)
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
$list1
|
||||
|
||||
ID X Y
|
||||
-- - -
|
||||
1 101 201
|
||||
2 102 202
|
||||
3 103 203
|
||||
4 104 204
|
||||
5 105 205
|
||||
6 106 206
|
||||
7 107 207
|
||||
8 108 208
|
||||
9 109 209
|
||||
|
||||
$list2
|
||||
|
||||
ID X Y
|
||||
-- - -
|
||||
1 101 201
|
||||
3 103 203
|
||||
5 105 205
|
||||
7 107 207
|
||||
9 109 209
|
||||
|
||||
Get-Lcs -ReferenceObject $list1.ID -DifferenceObject $list2.ID
|
||||
Loading…
Add table
Add a link
Reference in a new issue