Data update
This commit is contained in:
parent
ed705008a8
commit
0df55f9f24
2196 changed files with 32999 additions and 3075 deletions
|
|
@ -0,0 +1,25 @@
|
|||
proc shuffle . l[] .
|
||||
for i = len l[] downto 2
|
||||
r = randint i
|
||||
swap l[i] l[r]
|
||||
.
|
||||
.
|
||||
proc issorted . l[] r .
|
||||
for i = 2 to len l[]
|
||||
if l[i] < l[i - 1]
|
||||
r = 0
|
||||
return
|
||||
.
|
||||
.
|
||||
r = 1
|
||||
.
|
||||
proc bogosort . l[] .
|
||||
repeat
|
||||
issorted l[] r
|
||||
until r = 1
|
||||
shuffle l[]
|
||||
.
|
||||
.
|
||||
list[] = [ 2 7 41 11 3 1 6 5 8 ]
|
||||
bogosort list[]
|
||||
print list[]
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import "random" for Random
|
||||
import "/sort" for Sort
|
||||
import "./sort" for Sort
|
||||
|
||||
var bogoSort = Fn.new { |a|
|
||||
var rand = Random.new()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue