all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,15 @@
|
|||
permutationsort <- function(x)
|
||||
{
|
||||
if(!require(e1071) stop("the package e1071 is required")
|
||||
is.sorted <- function(x) all(diff(x) >= 0)
|
||||
|
||||
perms <- permutations(length(x))
|
||||
i <- 1
|
||||
while(!is.sorted(x))
|
||||
{
|
||||
x <- x[perms[i,]]
|
||||
i <- i + 1
|
||||
}
|
||||
x
|
||||
}
|
||||
permutationsort(c(1, 10, 9, 7, 3, 0))
|
||||
Loading…
Add table
Add a link
Reference in a new issue