Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,29 @@
|
|||
fn inOrder arr =
|
||||
(
|
||||
if arr.count < 2 then return true
|
||||
else
|
||||
(
|
||||
local i = 1
|
||||
while i < arr.count do
|
||||
(
|
||||
if arr[i+1] < arr[i] do return false
|
||||
i += 1
|
||||
)
|
||||
return true
|
||||
)
|
||||
)
|
||||
|
||||
fn permutations arr =
|
||||
(
|
||||
if arr.count <= 1 then return arr
|
||||
else
|
||||
(
|
||||
for i = 1 to arr.count do
|
||||
(
|
||||
local rest = for r in 1 to arr.count where r != i collect arr[r]
|
||||
local permRest = permutations rest
|
||||
local new = join #(arr[i]) permRest
|
||||
if inOrder new do return new
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
a = for i in 1 to 9 collect random 1 20
|
||||
#(10, 20, 17, 15, 17, 15, 3, 11, 15)
|
||||
permutations a
|
||||
#(3, 10, 11, 15, 15, 15, 17, 17, 20)
|
||||
Loading…
Add table
Add a link
Reference in a new issue