Skip to content

Instantly share code, notes, and snippets.

@orison09
Last active September 20, 2018 13:41
Show Gist options
  • Save orison09/c6577424bd153195231d86917ec2e567 to your computer and use it in GitHub Desktop.
Save orison09/c6577424bd153195231d86917ec2e567 to your computer and use it in GitHub Desktop.
FizzBuzz - SOA Week 2 Assignment 1
## 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