Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
2
Task/Knuth-shuffle/PowerShell/knuth-shuffle-1.ps1
Normal file
2
Task/Knuth-shuffle/PowerShell/knuth-shuffle-1.ps1
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
$A = 1, 2, 3, 4, 5
|
||||
Get-Random $A -Count $A.Count
|
||||
9
Task/Knuth-shuffle/PowerShell/knuth-shuffle-2.ps1
Normal file
9
Task/Knuth-shuffle/PowerShell/knuth-shuffle-2.ps1
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue