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,4 +0,0 @@
package Parameter is
X: Natural := 0;
Y: Natural;
end Parameter;

View file

@ -1,49 +0,0 @@
with Ada.Text_IO, Parameter, Hailstones;
procedure Hailstone is
-- if Parameter.X > 0, the length of Hailstone(Parameter.X)
-- is computed and written into Parameter.Y
-- if Parameter.X = 0, Hailstone(27) and N <= 100_000 with maximal
-- Hailstone(N) are computed and printed.
procedure Show_Sequence(N: Natural) is
Seq: Hailstones.Integer_Sequence := Hailstones.Create_Sequence(N);
begin
Ada.Text_IO.Put("Hailstone(" & Integer'Image(N) & " ) = (");
if Seq'Length < 8 then
for I in Seq'First .. Seq'Last-1 loop
Ada.Text_IO.Put(Integer'Image(Seq(I)) & ",");
end loop;
else
for I in Seq'First .. Seq'First+3 loop
Ada.Text_IO.Put(Integer'Image(Seq(I)) & ",");
end loop;
Ada.Text_IO.Put(" ...,");
for I in Seq'Last-3 .. Seq'Last-1 loop
Ada.Text_IO.Put(Integer'Image(Seq(I)) &",");
end loop;
end if;
Ada.Text_IO.Put_Line(Integer'Image(Seq(Seq'Last)) & " ); Length: " &
Integer'Image(seq'Length));
end Show_Sequence;
begin
if Parameter.X>0 then
Parameter.Y := Hailstones.Create_Sequence(Parameter.X)'Length;
else
Show_Sequence(27);
declare
Longest: Natural := 0;
Longest_Length: Natural := 0;
begin
for I in 2 .. 100_000 loop
if Hailstones.Create_Sequence(I)'Length > Longest_Length then
Longest := I;
Longest_Length := Hailstones.Create_Sequence(I)'Length;
end if;
end loop;
Ada.Text_IO.Put("Longest<=100_000: ");
Show_Sequence(Longest);
end;
end if;
end Hailstone;

View file

@ -1 +0,0 @@
procedure Hailstone;

View file

@ -1,35 +0,0 @@
with Hailstone, Parameter, Ada.Text_IO;
procedure Hailstone_Test is
Counts: array (1 .. 100_000) of Natural := (others => 0);
Max_Count: Natural := 0;
Most_Common: Positive := Counts'First;
Length: Natural renames Parameter.Y;
Sample: Natural := 0;
begin
for I in Counts'Range loop
Parameter.X := I;
Hailstone; -- compute the length of Hailstone(I)
Counts(Length) := Counts(Length)+1;
end loop;
for I in Counts'Range loop
if Counts(I) > Max_Count then
Max_Count := Counts(I);
Most_Common := I;
end if;
end loop;
Ada.Text_IO.Put_Line("Most frequent length:"
& Integer'Image(Most_Common)
& ";" & Integer'Image(Max_Count)
& " sequences of that length.");
for I in Counts'Range loop
Parameter.X := I;
Hailstone; -- compute the length of Hailstone(I)
if Length = Most_Common then
Sample := I;
exit;
end if;
end loop;
Ada.Text_IO.Put_Line("The first such sequence: Hailstone("
& Integer'Image(Sample) & " ).");
end Hailstone_Test;