Skip to content

Instantly share code, notes, and snippets.

@mcelaney
Last active August 31, 2016 13:32
Show Gist options
  • Save mcelaney/9910a377c9234fd120fcc64519c97d27 to your computer and use it in GitHub Desktop.
Save mcelaney/9910a377c9234fd120fcc64519c97d27 to your computer and use it in GitHub Desktop.
Normalish FizzBuzz
class FizzBuzz
def self.find_answers_for(max)
1.upto(max).each do |n|
result = ''
result << 'Fizz' if n % 3 == 0
result << 'Buzz' if n % 5 == 0
result = n if result.empty?
result
end
end
end
puts Benchmark.measure { FizzBuzz.find_answers_for(1000000) }
# 0.160000 0.010000 0.170000 ( 0.177896)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment