Last active
September 20, 2018 13:41
-
-
Save orison09/c6577424bd153195231d86917ec2e567 to your computer and use it in GitHub Desktop.
FizzBuzz - SOA Week 2 Assignment 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## write your fizzbuzz method in this file | |
# see http://en.wikipedia.org/wiki/Fizz_buzz for details on FizzBuzz game | |
# Version 1.3: Passes all tests. Rubocop. | |
def fizzbuzz(value) | |
fz = (1..value).to_a.map { |i| (i % 15) != 0 ? i : 'FizzBuzz' } | |
fz = fz.map { |i| (i % 5) != 0 ? i : 'Buzz' } | |
result = fz.map { |i| (i % 3) != 0 ? i : 'Fizz' } | |
result.map { |i| yield i } if block_given? | |
result | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment