September Morn Update

This commit is contained in:
Ingy döt Net 2019-09-12 10:33:56 -07:00
parent 4e2d22a71d
commit aac6731f2c
6856 changed files with 141342 additions and 21127 deletions

View file

@ -0,0 +1 @@
--- {}

View file

@ -1,12 +1,12 @@
sub swops(@a is copy) {
my $count = 0;
my int $count = 0;
until @a[0] == 1 {
@a[ ^@a[0] ] .= reverse;
$count++;
++$count;
}
return $count;
$count
}
sub topswops($n) { (sort map &swops, (1..$n).permutations)[*-1] }
sub topswops($n) { max (1..$n).permutations.race(:8degree).map: *.&swops }
say "$_ {topswops $_}" for 1 .. 10;

View file

@ -0,0 +1,25 @@
topswops <- function(x){
i <- 0
while(x[1] != 1){
first <- x[1]
if(first == length(x)){
x <- rev(x)
} else{
x <- c(x[first:1], x[(first+1):length(x)])
}
i <- i + 1
}
return(i)
}
library(iterpc)
result <- NULL
for(i in 1:10){
I <- iterpc(i, labels = 1:i, ordered = T)
A <- getall(I)
A <- data.frame(A)
A$flips <- apply(A, 1, topswops)
result <- rbind(result, c(i, max(A$flips)))
}