Data update

This commit is contained in:
Ingy döt Net 2024-07-13 15:19:22 -07:00
parent 29a5eea0d4
commit 5c1bb7bfa9
2011 changed files with 35081 additions and 3229 deletions

View file

@ -2,14 +2,14 @@ with Ada.Command_Line, Ada.Text_IO;
procedure Josephus is
function Arg(Idx, Default: Positive) return Positive is -- read Argument(Idx)
function Arg(Index, Default: Positive) return Natural is -- read Argument(Index)
(if Ada.Command_Line.Argument_Count >= Index
then Positive'Value(Ada.Command_Line.Argument(Index)) else Default);
then Natural'Value(Ada.Command_Line.Argument(Index)) else Default);
Prisoners: constant Positive := Arg(Idx => 1, Default => 41);
Steps: constant Positive := Arg(Idx => 2, Default => 3);
Survivors: constant Positive := Arg(Idx => 3, Default => 1);
Print: Boolean := (Arg(Idx => 4, Default => 1) = 1);
Prisoners: constant Positive := Arg(Index => 1, Default => 41);
Steps: constant Positive := Arg(Index => 2, Default => 3);
Survivors: constant Positive := Arg(Index => 3, Default => 1);
Print: Boolean := (Arg(Index => 4, Default => 1) = 1);
subtype Index_Type is Natural range 0 .. Prisoners-1;
Next: array(Index_Type) of Index_Type;
@ -20,8 +20,8 @@ begin
("N =" & Positive'Image(Prisoners) & ", K =" & Positive'Image(Steps) &
(if Survivors > 1 then ", #survivors =" & Positive'Image(Survivors)
else ""));
for Idx in Next'Range loop -- initialize Next
Next(Idx) := (Idx+1) mod Prisoners;
for Index in Next'Range loop -- initialize Next
Next(Index) := (Index+1) mod Prisoners;
end loop;
if Print then
Ada.Text_IO.Put("Executed: ");