September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
1
Task/Topswops/00META.yaml
Normal file
1
Task/Topswops/00META.yaml
Normal file
|
|
@ -0,0 +1 @@
|
|||
--- {}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
25
Task/Topswops/R/topswops.r
Normal file
25
Task/Topswops/R/topswops.r
Normal 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)))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue