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,28 +0,0 @@
-- Permutations by swapping
-- J. Carter 2024 Jun
-- Uses the PragmAda Reusable Components (https://github.com/jrcarter/PragmARC)
with Ada.Text_IO;
with PragmARC.Permutations;
procedure Permutations_By_Swapping is
package Permutations is new PragmARC.Permutations (Element => Positive);
Permutation : Permutations.Sequence_Lists.Vector;
begin -- Permutations_By_Swapping
Permutations.Generate (Initial => (1, 2, 3), Result => Permutation);
Output : for I in 1 .. Permutation.Last_Index loop
One_Permutation : declare
Sequence : Permutations.Sequence renames Permutation.Element (I);
begin -- One_Permutation
Ada.Text_IO.Put (Item => '(');
Print : for J in Sequence'Range loop
Ada.Text_IO.Put (Item => (if J > 1 then "," else "") & Sequence (J)'Image);
end loop Print;
Ada.Text_IO.Put_Line (Item => ") " & (if I rem 2 = 0 then '-' else '+') & '1');
end One_Permutation;
end loop Output;
end Permutations_By_Swapping;

View file

@ -1,10 +1,10 @@
permutations: function [arr][
d: 1
c: array.of: size arr 0
xs: new arr
xs: @ arr
sign: 1
ret: new @[@[xs, sign]]
ret: @[@[new xs, sign]]
while [true][
while [d > 1][
@ -23,7 +23,7 @@ permutations: function [arr][
xs\[d]: tmp
sign: neg sign
'ret ++ @[new @[xs, sign]]
'ret ++ @[@[new xs, sign]]
c\[d]: c\[d] + 1
]

View file

@ -1,37 +0,0 @@
function output([Object[]]$A, [Int]$k, [ref]$sign)
{
"Perm: [$([String]::Join(', ', $A))] Sign: $($sign.Value)"
}
function permutation([Object[]]$array)
{
function generate([Object[]]$A, [Int]$k, [ref]$sign)
{
if($k -eq 1)
{
output $A $k $sign
$sign.Value = -$sign.Value
}
else
{
$k -= 1
generate $A $k $sign
for([Int]$i = 0; $i -lt $k; $i += 1)
{
if($i % 2 -eq 0)
{
$A[$i], $A[$k] = $A[$k], $A[$i]
}
else
{
$A[0], $A[$k] = $A[$k], $A[0]
}
generate $A $k $sign
}
}
}
generate $array $array.Count ([ref]1)
}
permutation @(0, 1, 2)
""
permutation @(0, 1, 2, 3)