Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,31 +0,0 @@
|
|||
with Ada.Command_Line, Ada.Text_IO, Ada.Strings.Fixed;
|
||||
|
||||
procedure Rep_String is
|
||||
|
||||
function Find_Largest_Rep_String(S:String) return String is
|
||||
L: Natural := S'Length;
|
||||
begin
|
||||
for I in reverse 1 .. L/2 loop
|
||||
declare
|
||||
use Ada.Strings.Fixed;
|
||||
T: String := S(S'First .. S'First + I-1); -- the first I characters of S
|
||||
U: String := (1+(L/I)) * T; -- repeat T so often that U'Length >= L
|
||||
begin -- compare first L characers of U with S
|
||||
if U(U'First .. U'First + S'Length -1) = S then
|
||||
return T; -- T is a rep-string
|
||||
end if;
|
||||
end;
|
||||
end loop;
|
||||
return ""; -- no rep string;
|
||||
end Find_Largest_Rep_String;
|
||||
|
||||
X: String := Ada.Command_Line.Argument(1);
|
||||
Y: String := Find_Largest_Rep_String(X);
|
||||
|
||||
begin
|
||||
if Y="" then
|
||||
Ada.Text_IO.Put_Line("No rep-string for """ & X & """");
|
||||
else
|
||||
Ada.Text_IO.Put_Line("Longest rep-string for """& X &""": """& Y &"""");
|
||||
end if;
|
||||
end Rep_String;
|
||||
|
|
@ -24,8 +24,7 @@ strings: {
|
|||
|
||||
loop split.lines strings 'str [
|
||||
rep: repeated? str
|
||||
if? false = rep ->
|
||||
print [str "-> *not* a rep-string"]
|
||||
else ->
|
||||
print [str "->" rep "( length:" size rep ")"]
|
||||
switch false = rep
|
||||
-> print [str "-> *not* a rep-string"]
|
||||
-> print [str "->" rep "( length:" size rep ")"]
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
Function rep_string(s)
|
||||
max_len = Int(Len(s)/2)
|
||||
tmp = ""
|
||||
If max_len = 0 Then
|
||||
rep_string = "No Repeating String"
|
||||
Exit Function
|
||||
End If
|
||||
For i = 1 To max_len
|
||||
If InStr(i+1,s,tmp & Mid(s,i,1))Then
|
||||
tmp = tmp & Mid(s,i,1)
|
||||
Else
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
Do While Len(tmp) > 0
|
||||
If Mid(s,Len(tmp)+1,Len(tmp)) = tmp Then
|
||||
rep_string = tmp
|
||||
Exit Do
|
||||
Else
|
||||
tmp = Mid(tmp,1,Len(tmp)-1)
|
||||
End If
|
||||
Loop
|
||||
If Len(tmp) > 0 Then
|
||||
rep_string = tmp
|
||||
Else
|
||||
rep_string = "No Repeating String"
|
||||
End If
|
||||
End Function
|
||||
|
||||
'testing the function
|
||||
arr = Array("1001110011","1110111011","0010010010","1010101010",_
|
||||
"1111111111","0100101101","0100100","101","11","00","1")
|
||||
|
||||
For n = 0 To UBound(arr)
|
||||
WScript.StdOut.Write arr(n) & ": " & rep_string(arr(n))
|
||||
WScript.StdOut.WriteLine
|
||||
Next
|
||||
Loading…
Add table
Add a link
Reference in a new issue