fizzbuzz | R Documentation |
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.
fizzbuzz(n, show_numbers = TRUE)
fizzbuzz_lazy(n)
.fizzbuzz_vector
n |
The number of numbers |
show_numbers |
If |
An object of class character
of length 1000000.
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
A character
vector of 1, 2, Fizz, 3, Buzz
, etc
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))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.