#' Generates a response, given a code and a guess
#'
#' @param code numeric vector of length 1 to 9
#' @param guess numeric vector of length 1 to 9
#'
#' @return named vector of length 2, with names 'black'
#' and 'white'
#' @export
#'
#' @examples
#' response(code = c(1, 2, 3, 4), guess = c(1, 2, 4, 3))
#'
response <- function(code, guess) {
black <- sum(code == guess)
white <- min(sum(guess %in% code), sum(code %in% guess)) - black
return(c(black = black, white = white))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.