fizzbuzz {mark} | R 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 |
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))
}
[Package mark version 0.8.0 Index]