# R/makeFizzbuzzProblem.R In ja-thomas/dlbench: Deep Learning Benchmark Problems

#### Documented in makeFizzbuzzProblem

#' @title Fizzbuzz Classification Problem
#'
#' @description
#' This problem is inspired by this blog post \url{http://joelgrus.com/2016/05/23/fizz-buzz-in-tensorflow/}.
#' Obviously this is not a serious benchmarking problem, but it isn't totally trivial to solve.
#' Each observation is one number encoded in 32-bit binary. The target if
#' \itemize{
#'  \item{\code{"fizz"} if the number is dividable by 3.}
#'  \item{\code{"buzz"} if the number is dividable by 5.}
#'  \item{\code{"fizzbuzz"} if the number is dividable by 15.}
#'  \item{\code{"number"} otherwise.}
#' }
#' @param n [\code{integer(1)}]\cr
#'   Number of observations to create.
#'   Default is \code{5000L}.
#'   is returned. Otherwise a \code{data.frame} is returned.
#' @examples
#' @export
makeFizzbuzzProblem = function(n = 10^4, create.task = TRUE) {

assertIntegerish(n, lower = 1)

n = seq_len(n)
target = ifelse(n %% 15 == 0, "fizzbuzz", ifelse(n %% 5 == 0, "buzz", ifelse(n %% 3 == 0, "fizz", "number")))
x = vapply(n, function(x) as.integer(intToBits(x)), FUN.VALUE = numeric(32))

res = data.frame(target, t(x))

res = res[sample(n), ]