fork download
  1. move <- function(i, j, r)
  2. {
  3. x <- c(i, j)
  4. A[x, ] <<- A[x, ] + c(-r, r) %o% A[i, ]
  5. }
  6.  
  7. A <- cbind(rep(1, 3), c(0.25, 0.33, 0.50))
  8. B <- rbind(c(0, 1, 0.1), c(1, 2, 0.2), c(0, 2, 0.3))
  9. k <- 2
  10.  
  11. apply(B, 1, function(v) move(v[1] + 1, v[2] + 1, v[3])) -> .
  12. cat(A[k + 1, 2] / A[k + 1, 1], "\n", sep = "")
Success #stdin #stdout 0.24s 43272KB
stdin
Standard input is empty
stdout
0.4285235