Sha256: 71f69a69c84c98d8fc5252eb5f2ce8e90aaf320d6c26241484ef6d33d6813672
Contents?: true
Size: 482 Bytes
Versions: 219
Compression:
Stored size: 482 Bytes
Contents
largest_series_product <- function(digits, span){ nums <- as.numeric(unlist(strsplit(digits, ""))) if (any(is.na(nums)) || span < 0 || span > length(nums)) { stop("Non-numeric characters or span less than digit length") } if (span == 0) { return(1) } indices <- 1:(length(nums) - span + 1) get_prod <- function(index, nums, span) { prod(nums[index:(index + span - 1)]) } products <- sapply(indices, FUN = get_prod, nums, span) max(products) }
Version data entries
219 entries across 219 versions & 1 rubygems