June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -0,0 +1,16 @@
names = unlist(strsplit("baker cooper fletcher miller smith", " "))
test <- function(floors) {
f <- function(name) which(name == floors)
if ((f('baker') != 5) &&
(f('cooper') != 1) &&
(any(f('fletcher') == 2:4)) &&
(f('miller') > f('cooper')) &&
(abs(f('fletcher') - f('cooper')) > 1) &&
(abs(f('smith') - f('fletcher')) > 1))
cat("\nFrom bottom to top: --> ", floors, "\n")
}
do.perms <- function(seq, func, built = c()){
if (0 == length(seq)) func(built)
else for (x in seq) do.perms( seq[!seq==x], func, c(x, built)) }

View file

@ -0,0 +1,7 @@
> do.perms(names, test)
From bottom to top: --> smith cooper baker fletcher miller
> system.time(do.perms(names, test))
From bottom to top: --> smith cooper baker fletcher miller
user system elapsed
0 0 0