Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
14
Task/Knuth-shuffle/AppleScript/knuth-shuffle-1.applescript
Normal file
14
Task/Knuth-shuffle/AppleScript/knuth-shuffle-1.applescript
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
set n to 25
|
||||
|
||||
set array to {}
|
||||
repeat with i from 1 to n
|
||||
set end of array to i
|
||||
end repeat
|
||||
copy {array, array} to {unshuffled, shuffled}
|
||||
repeat with i from n to 1 by -1
|
||||
set j to (((random number) * (i - 1)) as integer) + 1
|
||||
set shuffled's item i to array's item j
|
||||
if j ≠ i's contents then set array's item j to array's item i
|
||||
end repeat
|
||||
|
||||
return {unshuffled, shuffled}
|
||||
Loading…
Add table
Add a link
Reference in a new issue