Skip to content

Instantly share code, notes, and snippets.

@chriszf
Created April 9, 2012 08:07
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chriszf/2342247 to your computer and use it in GitHub Desktop.
Save chriszf/2342247 to your computer and use it in GitHub Desktop.
FizzBuzz without conditionals
# SCREW YOU CONDITIONALS
def fizzbuzz(n):
fizzes = [1, 0, 0]
buzzes = [2, 0, 0, 0, 0]
words = [None, "Fizz", "Buzz", "FizzBuzz"]
for i in range(1, n):
words[0] = i
print(words[fizzes[i%3] + buzzes[i%5]])
fizzbuzz(20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment