Skip to content

Instantly share code, notes, and snippets.

@rosslebeau
Last active June 12, 2016 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rosslebeau/3c860fc43aec7f203a0bde2fc98e1ac4 to your computer and use it in GitHub Desktop.
Save rosslebeau/3c860fc43aec7f203a0bde2fc98e1ac4 to your computer and use it in GitHub Desktop.
An insane, one-line solution to FizzBuzz in Ruby, using no conditionals.
def fizzbuzz(start, limit) loop do puts "#{'fizz' * (((start % 3 / (start % 3 + 1.0)).ceil - 1) * (-1))}#{'buzz' * (((start % 5 / (start % 5 + 1.0)).ceil - 1) * (-1))}#{start.to_s * ((start % 3 / (start % 3 + 1.0)).ceil * ((start % 5) / ((((start += ((limit + 1) - start)/((limit + 1) - start)) - 1) % 5) + 1.0)).ceil)}" end end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment