Skip to content

Instantly share code, notes, and snippets.

@siciliana
Created July 24, 2013 15:26
Show Gist options
  • Select an option

  • Save siciliana/6071603 to your computer and use it in GitHub Desktop.

Select an option

Save siciliana/6071603 to your computer and use it in GitHub Desktop.
def super_fizzbuzz(array)
new_arr = []
(array).each do |i|
if (i % 3).zero? && (i % 15) != 0
puts new_arr <<'Fizz'
elsif (i % 5).zero? && (i % 15) != 0
puts new_arr << 'Buzz'
elsif (i % 15).zero?
puts new_arr <<'FizzBuzz'
else
puts i
end
end
end
@siciliana
Copy link
Author

SCORE!!

def super_fizzbuzz(array)
(array).map! { |i|
if (i % 3).zero? && (i % 15) != 0
'Fizz'
elsif (i % 5).zero? && (i % 15) != 0
'Buzz'
elsif (i % 15).zero?
'FizzBuzz'
else
i
end
}
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment