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,29 +0,0 @@
function shuffle ($a) {
$c = $a.Clone() # make copy to avoid clobbering $a
1..($c.Length - 1) | ForEach-Object {
$i = Get-Random -Minimum $_ -Maximum $c.Length
$c[$_-1],$c[$i] = $c[$i],$c[$_-1]
$c[$_-1] # return newly-shuffled value
}
$c[-1] # last value
}
function isSorted( [Array] $data )
{
$sorted = $true
for( $i = 1; ( $i -lt $data.length ) -and $sorted; $i++ )
{
$sorted = $data[ $i - 1 ] -le $data[ $i ]
}
$sorted
}
function BogoSort ( [Array] $indata ) {
$data = $indata.Clone()
while( -not ( isSorted $data ) ) {
$data = shuffle $indata
}
$data
}
$l = 7; BogoSort ( 1..$l | ForEach-Object { $Rand = New-Object Random }{ $Rand.Next( 0, $l - 1 ) } )