add names to r files
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
# Josua Kugler, Christian Merten
|
||||||
|
|
||||||
`%o%` <- function(f, g) {
|
`%o%` <- function(f, g) {
|
||||||
comp <- function(...) {
|
comp <- function(...) {
|
||||||
return(f(g(...)))
|
return(f(g(...)))
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
# Josua Kugler, Christian Merten
|
||||||
|
|
||||||
n_diag <- function(mat, n) {
|
n_diag <- function(mat, n) {
|
||||||
stopifnot("Matrix not quadratic" = nrow(mat) == ncol(mat))
|
stopifnot("Matrix not quadratic" = nrow(mat) == ncol(mat))
|
||||||
stopifnot("Matrix does not have such a (sub)diagonal" = abs(n) < nrow(mat))
|
stopifnot("Matrix does not have such a (sub)diagonal" = abs(n) < nrow(mat))
|
||||||
|
|||||||
+4
-10
@@ -1,3 +1,5 @@
|
|||||||
|
# Josua Kugler, Christian Merten
|
||||||
|
|
||||||
## 1.
|
## 1.
|
||||||
|
|
||||||
size <- function(mat) {
|
size <- function(mat) {
|
||||||
@@ -98,16 +100,8 @@ is_solution_of <- function(s, s_star) {
|
|||||||
|
|
||||||
print_non_valid <- function(s, print_missing=T) {
|
print_non_valid <- function(s, print_missing=T) {
|
||||||
stopifnot("s is not a sudoku!" = is_sudoku(s))
|
stopifnot("s is not a sudoku!" = is_sudoku(s))
|
||||||
s <- ""
|
|
||||||
if (print_missing) {
|
if (print_missing) {
|
||||||
missing_fields <- which(is.na(s), arr.ind=T)
|
apply(which(is.na(s), arr.ind=T), 1, function(x) cat("missing value at ", x[1], ",", x[2], "\n", sep=""))
|
||||||
if (nrow(missing_fields) > 0)
|
|
||||||
sapply(1:nrow(missing_fields), function(r) cat("missing value at ",
|
|
||||||
missing_fields[r,1],
|
|
||||||
",",
|
|
||||||
missing_fields[r,2],
|
|
||||||
"\n",
|
|
||||||
sep=""))
|
|
||||||
}
|
}
|
||||||
n <- size(s)[1]
|
n <- size(s)[1]
|
||||||
m <- size(s)[2]
|
m <- size(s)[2]
|
||||||
@@ -132,7 +126,7 @@ print_non_valid <- function(s, print_missing=T) {
|
|||||||
" is invalid\n",
|
" is invalid\n",
|
||||||
sep=""))
|
sep=""))
|
||||||
}
|
}
|
||||||
return(NULL)
|
invisible(NULL)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user