6 kyu
Custom FizzBuzz Array
699 of 3,664ogryzek
Description:
Write a function that returns a (custom) FizzBuzz sequence of the numbers 1 to 100
.
The function should be able to take up to 4 arguments:
- The 1st and 2nd arguments are strings,
"Fizz"
and"Buzz"
by default; - The 3rd and 4th arguments are integers,
3
and5
by default.
Thus, when the function is called without arguments, it will return the classic FizzBuzz sequence up to 100:
[ 1, 2, "Fizz", 4, "Buzz", "Fizz", 7, ... 14, "FizzBuzz", 16, 17, ... 98, "Fizz", "Buzz" ]
When the function is called with (up to 4) arguments, it should return a custom FizzBuzz sequence, for example:
('Hey', 'There') --> [ 1, 2, "Hey", 4, "There", "Hey", ... ]
('Foo', 'Bar', 2, 3) --> [ 1, "Foo", "Bar", "Foo", 5, "FooBar", 7, ... ]
Examples
fizz_buzz_custom[15] # returns 16
fizz_buzz_custom[44] # returns "FizzBuzz" (45 is divisible by 3 and 5)
fizz_buzz_custom('Hey', 'There')[25] # returns 26
fizz_buzz_custom('Hey', 'There')[11] # returns "Hey" (12 is divisible by 3)
fizz_buzz_custom("What's ", "up?", 3, 7)[80] # returns "What's " (81 is divisible by 3)
Arrays
Logic
Fundamentals
Similar Kata:
Stats:
Created | Apr 21, 2014 |
Published | Apr 21, 2014 |
Warriors Trained | 6637 |
Total Skips | 1423 |
Total Code Submissions | 26042 |
Total Times Completed | 3664 |
Ruby Completions | 699 |
JavaScript Completions | 2185 |
Python Completions | 721 |
Rust Completions | 130 |
Total Stars | 110 |
% of votes with a positive feedback rating | 88% of 480 |
Total "Very Satisfied" Votes | 380 |
Total "Somewhat Satisfied" Votes | 85 |
Total "Not Satisfied" Votes | 15 |