Parcourir la source

add names to r files

master
flavis il y a 4 ans
Parent
révision
ae3841f6a9
3 fichiers modifiés avec 8 ajouts et 10 suppressions
  1. +2
    -0
      sose2021/r/w03/P03-1.R
  2. +2
    -0
      sose2021/r/w03/P03-2.R
  3. +4
    -10
      sose2021/r/w03/P03-3.R

+ 2
- 0
sose2021/r/w03/P03-1.R Voir le fichier

@@ -1,3 +1,5 @@
# Josua Kugler, Christian Merten

`%o%` <- function(f, g) {
comp <- function(...) {
return(f(g(...)))


+ 2
- 0
sose2021/r/w03/P03-2.R Voir le fichier

@@ -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))


+ 4
- 10
sose2021/r/w03/P03-3.R Voir le fichier

@@ -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)
}


Chargement…
Annuler
Enregistrer