fizzbuzz: Fizz Buzz

View source: R/fizzbuzz.R

fizzbuzzR Documentation

Fizz Buzz

Description

For when someone asked you to do something you've done before, you can argue that the quickest way to do it is to just take the work someone else did and utilize that. No reason to reinvent the wheel.

Usage

fizzbuzz(n, show_numbers = TRUE)

fizzbuzz_lazy(n)

.fizzbuzz_vector

Arguments

n

The number of numbers

show_numbers

If TRUE shows no

Format

An object of class character of length 1000000.

Details

Multiples of 3 are shown as "Fizz"; multiples of 5 as "Buzz"; multiple of both (i.e., 15) are "FizzBuzz". fizzbuzz_lazy() subsets the .fizzbuzz_vector object, which is a solution with default parameters up to 1e6

Value

A character vector of ⁠1, 2, Fizz, 3, Buzz⁠, etc

Examples

fizzbuzz(15)
fizzbuzz(30, show_numbers = FALSE)
cat(fizzbuzz(30), sep = "\n")


# show them how fast your solution is:
if (package_available("bench")) {
  bench::mark(fizzbuzz(1e5), fizzbuzz_lazy(1e5))
}


mark documentation built on Oct. 23, 2023, 9:06 a.m.