Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,7 +0,0 @@
package Hofstadter_Figure_Figure is
function FFR(P: Positive) return Positive;
function FFS(P: Positive) return Positive;
end Hofstadter_Figure_Figure;

View file

@ -1,51 +0,0 @@
package body Hofstadter_Figure_Figure is
type Positive_Array is array (Positive range <>) of Positive;
function FFR(P: Positive) return Positive_Array is
Figures: Positive_Array(1 .. P+1);
Space: Positive := 2;
Space_Index: Positive := 2;
begin
Figures(1) := 1;
for I in 2 .. P loop
Figures(I) := Figures(I-1) + Space;
Space := Space+1;
while Space = Figures(Space_Index) loop
Space := Space + 1;
Space_Index := Space_Index + 1;
end loop;
end loop;
return Figures(1 .. P);
end FFR;
function FFR(P: Positive) return Positive is
Figures: Positive_Array(1 .. P) := FFR(P);
begin
return Figures(P);
end FFR;
function FFS(P: Positive) return Positive_Array is
Spaces: Positive_Array(1 .. P);
Figures: Positive_Array := FFR(P+1);
J: Positive := 1;
K: Positive := 1;
begin
for I in Spaces'Range loop
while J = Figures(K) loop
J := J + 1;
K := K + 1;
end loop;
Spaces(I) := J;
J := J + 1;
end loop;
return Spaces;
end FFS;
function FFS(P: Positive) return Positive is
Spaces: Positive_Array := FFS(P);
begin
return Spaces(P);
end FFS;
end Hofstadter_Figure_Figure;

View file

@ -1,40 +0,0 @@
with Ada.Text_IO, Hofstadter_Figure_Figure;
procedure Test_HSS is
use Hofstadter_Figure_Figure;
A: array(1 .. 1000) of Boolean := (others => False);
J: Positive;
begin
for I in 1 .. 10 loop
Ada.Text_IO.Put(Integer'Image(FFR(I)));
end loop;
Ada.Text_IO.New_Line;
for I in 1 .. 40 loop
J := FFR(I);
if A(J) then
raise Program_Error with Positive'Image(J) & " used twice";
end if;
A(J) := True;
end loop;
for I in 1 .. 960 loop
J := FFS(I);
if A(J) then
raise Program_Error with Positive'Image(J) & " used twice";
end if;
A(J) := True;
end loop;
for I in A'Range loop
if not A(I) then raise Program_Error with Positive'Image(I) & " unused";
end if;
end loop;
Ada.Text_IO.Put_Line("Test Passed: No overlap between FFR(I) and FFS(J)");
exception
when Program_Error => Ada.Text_IO.Put_Line("Test Failed"); raise;
end Test_HSS;

View file

@ -1,2 +0,0 @@
1 3 7 12 18 26 35 45 56 69
Test Passed: No overlap between FFR(I) and FFS(J)

View file

@ -1,70 +0,0 @@
'Initialize the r and the s arrays.
Set r = CreateObject("System.Collections.ArrayList")
Set s = CreateObject("System.Collections.ArrayList")
'Set initial values of r.
r.Add "" : r.Add 1
'Set initial values of s.
s.Add "" : s.Add 2
'Populate the r and the s arrays.
For i = 2 To 1000
ffr(i)
ffs(i)
Next
'r function
Function ffr(n)
r.Add r(n-1)+s(n-1)
End Function
's function
Function ffs(n)
'index is the value of the last element of the s array.
index = s(n-1)+1
Do
'Add to s if the current index is not in the r array.
If r.IndexOf(index,0) = -1 Then
s.Add index
Exit Do
Else
index = index + 1
End If
Loop
End Function
'Display the first 10 values of r.
WScript.StdOut.Write "First 10 Values of R:"
WScript.StdOut.WriteLine
For j = 1 To 10
If j = 10 Then
WScript.StdOut.Write "and " & r(j)
Else
WScript.StdOut.Write r(j) & ", "
End If
Next
WScript.StdOut.WriteBlankLines(2)
'Show that the first 40 values of r plus the first 960 values of s include all the integers from 1 to 1000 exactly once.
'The idea here is to create another array(integer) with 1000 elements valuing from 1 to 1000. Go through the first 40 values
'of the r array and remove the corresponding element in the integer array. Do the same thing with the first 960 values of
'the s array. If the resultant count of the integer array is 0 then it is a pass.
Set integers = CreateObject("System.Collections.ArrayList")
For k = 1 To 1000
integers.Add k
Next
For l = 1 To 960
If l <= 40 Then
integers.Remove(r(l))
End If
integers.Remove(s(l))
Next
WScript.StdOut.Write "Test for the first 1000 integers: "
If integers.Count = 0 Then
WScript.StdOut.Write "Passed!!!"
WScript.StdOut.WriteLine
Else
WScript.StdOut.Write "Miserably Failed!!!"
WScript.StdOut.WriteLine
End If