Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,28 @@
queens <- function(n) {
a <- seq(n)
u <- rep(T, 2 * n - 1)
v <- rep(T, 2 * n - 1)
m <- NULL
aux <- function(i) {
if (i > n) {
m <<- cbind(m, a)
} else {
for (j in seq(i, n)) {
k <- a[[j]]
p <- i - k + n
q <- i + k - 1
if (u[[p]] && v[[q]]) {
u[[p]] <<- v[[q]] <<- F
a[[j]] <<- a[[i]]
a[[i]] <<- k
aux(i + 1)
u[[p]] <<- v[[q]] <<- T
a[[i]] <<- a[[j]]
a[[j]] <<- k
}
}
}
}
aux(1)
m
}

View file

@ -0,0 +1,3 @@
library(Matrix)
a <- queens(8)
as(a[, 1], "pMatrix")

View file

@ -0,0 +1 @@
sapply(4:12, function(n) ncol(queens(n)))