Skip to content

Instantly share code, notes, and snippets.

@alexymik
Last active May 18, 2016 15:19
Show Gist options
  • Save alexymik/7520e0fa171f7893c136a11cb3374791 to your computer and use it in GitHub Desktop.
Save alexymik/7520e0fa171f7893c136a11cb3374791 to your computer and use it in GitHub Desktop.
Ruby Fizz Buzz
# Powered by Ruby™
# This is meant to be satire
def fizz_buzz_start
1
end
def fizz_buzz_limit
100
end
def fizz
'fizz'
end
def buzz
'buzz'
end
def fizzbuzz
'fizzbuzz'
end
def is_fizzbuzz?(num)
num % 15 == 0
end
def is_fizz?(num)
num % 3 == 0 && num % 15 != 0
end
def is_buzz?(num)
num % 5 == 0 && num % 15 != 0
end
def not_fizz_not_buzz_not_fizzbuzz(num)
num % 3 != 0 && num % 5 != 0
end
fizz_buzz_start.upto(fizz_buzz_limit) do |num|
puts fizzbuzz if is_fizzbuzz? num
puts fizz if is_fizz? num
puts buzz if is_buzz? num
puts num if not_fizz_not_buzz_not_fizzbuzz num
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment