Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -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
)
)
)

View file

@ -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)