Last active
August 29, 2015 14:06
-
-
Save amonmoce/ebd6d7c17d2017097853 to your computer and use it in GitHub Desktop.
A fizzbuzz implementation in Ruby language with map ... Rubocop tested "no offense"
This file contains 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
def fizzbuzz(n) | |
numbers = Array.new(n) { |i| i + 1 } | |
numbers.map! { |x| x % 3 == 0 && x % 5 != 0 ? 'Fizz' : x } | |
numbers.map! { |x| x % 5 == 0 && x % 3 != 0 ? 'Buzz' : x } | |
numbers.map! { |x| x % 15 == 0 ? 'FizzBuzz' : x } | |
print numbers | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment