diff --git a/sose2021/r/w03/P03-1.R b/sose2021/r/w03/P03-1.R index 19151e3..54ef103 100644 --- a/sose2021/r/w03/P03-1.R +++ b/sose2021/r/w03/P03-1.R @@ -1,3 +1,5 @@ +# Josua Kugler, Christian Merten + `%o%` <- function(f, g) { comp <- function(...) { return(f(g(...))) diff --git a/sose2021/r/w03/P03-2.R b/sose2021/r/w03/P03-2.R index 32cc5de..790c821 100644 --- a/sose2021/r/w03/P03-2.R +++ b/sose2021/r/w03/P03-2.R @@ -1,3 +1,5 @@ +# Josua Kugler, Christian Merten + n_diag <- function(mat, n) { stopifnot("Matrix not quadratic" = nrow(mat) == ncol(mat)) stopifnot("Matrix does not have such a (sub)diagonal" = abs(n) < nrow(mat)) diff --git a/sose2021/r/w03/P03-3.R b/sose2021/r/w03/P03-3.R index a671d8f..2549c08 100644 --- a/sose2021/r/w03/P03-3.R +++ b/sose2021/r/w03/P03-3.R @@ -1,3 +1,5 @@ +# Josua Kugler, Christian Merten + ## 1. size <- function(mat) { @@ -98,16 +100,8 @@ is_solution_of <- function(s, s_star) { print_non_valid <- function(s, print_missing=T) { stopifnot("s is not a sudoku!" = is_sudoku(s)) - s <- "" if (print_missing) { - missing_fields <- which(is.na(s), arr.ind=T) - 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="")) + apply(which(is.na(s), arr.ind=T), 1, function(x) cat("missing value at ", x[1], ",", x[2], "\n", sep="")) } n <- size(s)[1] m <- size(s)[2] @@ -132,7 +126,7 @@ print_non_valid <- function(s, print_missing=T) { " is invalid\n", sep="")) } - return(NULL) + invisible(NULL) }