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,39 +0,0 @@
-- Permutation sort
-- J. Carter 2024 Jun
-- Uses the PragmAda Reusable Components (https://github.com/jrcarter/PragmARC)
with Ada.Text_IO;
with PragmARC.Permutations;
procedure Slow_Sort is
package Char_Perms is new PragmARC.Permutations (Element => Character);
procedure Put (Item : in Char_Perms.Sequence);
-- Outputs all the Characters in Item to standard output, followed by a line terminator
procedure Process (Seq : in Char_Perms.Sequence; Stop : in out Boolean);
-- If Seq is sorted, outputs it and sets Stop to True
procedure Put (Item : in Char_Perms.Sequence) is
-- Empty
begin -- Put
All_Chars : for C of Item loop
Ada.Text_IO.Put (Item => C);
end loop All_Chars;
Ada.Text_IO.New_Line;
end Put;
procedure Process (Seq : in Char_Perms.Sequence; Stop : in out Boolean) is
-- Empty
begin -- Process
if (for all J in 1 .. Seq'Last - 1 => Seq (J) <= Seq (J + 1) ) then -- Sorted
Put (Item => Seq);
Stop := True;
end if;
end Process;
Test : constant Char_Perms.Sequence := "kjihgfedcba";
begin -- Slow_Sort
Char_Perms.Generate (Initial => Test, Process => Process'Access);
end Slow_Sort;

View file

@ -1,20 +1,18 @@
(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
with javascript_semantics
<span style="color: #008080;">function</span> <span style="color: #000000;">inOrder</span><span style="color: #0000FF;">(</span><span style="color: #004080;">sequence</span> <span style="color: #000000;">s</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">=</span><span style="color: #000000;">2</span> <span style="color: #008080;">to</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">do</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">]<</span><span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">-</span><span style="color: #000000;">1</span><span style="color: #0000FF;">]</span> <span style="color: #008080;">then</span> <span style="color: #008080;">return</span> <span style="color: #004600;">false</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #008080;">return</span> <span style="color: #004600;">true</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
function inOrder(sequence s)
for i=2 to length(s) do
if s[i]<s[i-1] then return false end if
end for
return true
end function
<span style="color: #008080;">function</span> <span style="color: #000000;">permutationSort</span><span style="color: #0000FF;">(</span><span style="color: #004080;">sequence</span> <span style="color: #000000;">s</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">for</span> <span style="color: #000000;">n</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #7060A8;">factorial</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">))</span> <span style="color: #008080;">do</span>
<span style="color: #004080;">sequence</span> <span style="color: #000000;">perm</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">permute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">n</span><span style="color: #0000FF;">,</span><span style="color: #000000;">s</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">inOrder</span><span style="color: #0000FF;">(</span><span style="color: #000000;">perm</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">then</span> <span style="color: #008080;">return</span> <span style="color: #000000;">perm</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #0000FF;">?</span><span style="color: #000000;">9</span><span style="color: #0000FF;">/</span><span style="color: #000000;">0</span> <span style="color: #000080;font-style:italic;">-- should never happen</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
function permutationSort(sequence s)
for n=1 to factorial(length(s)) do
sequence perm = permute(n,s)
if inOrder(perm) then return perm end if
end for
?9/0 -- should never happen
end function
<span style="color: #0000FF;">?</span><span style="color: #000000;">permutationSort</span><span style="color: #0000FF;">({</span><span style="color: #008000;">"dog"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">15.545</span><span style="color: #0000FF;">,{</span><span style="color: #008000;">"cat"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"pile"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"abcde"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">},</span><span style="color: #008000;">"cat"</span><span style="color: #0000FF;">})</span>
<!--
?permutationSort({"dog",0,15.545,{"cat","pile","abcde",1},"cat"})

View file

@ -1,40 +0,0 @@
Function PermutationSort( [Object[]] $indata, $index = 0, $k = 0 )
{
$data = $indata.Clone()
$datal = $data.length - 1
if( $datal -gt 0 ) {
for( $j = $index; $j -lt $datal; $j++ )
{
$sorted = ( PermutationSort $data ( $index + 1 ) $j )[0]
if( -not $sorted )
{
$temp = $data[ $index ]
$data[ $index ] = $data[ $j + 1 ]
$data[ $j + 1 ] = $temp
}
}
if( $index -lt ( $datal - 1 ) )
{
PermutationSort $data ( $index + 1 ) $j
} else {
$sorted = $true
for( $i = 0; ( $i -lt $datal ) -and $sorted; $i++ )
{
$sorted = ( $data[ $i ] -le $data[ $i + 1 ] )
}
$sorted
$data
}
}
}
0..4 | ForEach-Object { $a = $_; 0..4 | Where-Object { -not ( $_ -match "$a" ) } |
ForEach-Object { $b = $_; 0..4 | Where-Object { -not ( $_ -match "$a|$b" ) } |
ForEach-Object { $c = $_; 0..4 | Where-Object { -not ( $_ -match "$a|$b|$c" ) } |
ForEach-Object { $d = $_; 0..4 | Where-Object { -not ( $_ -match "$a|$b|$c|$d" ) } |
ForEach-Object { $e=$_; "$( PermutationSort ( $a, $b, $c, $d, $e ) )" }
}
}
}
}
$l = 8; PermutationSort ( 1..$l | ForEach-Object { $Rand = New-Object Random }{ $Rand.Next( 0, $l - 1 ) } )