Created
April 9, 2012 08:07
-
-
Save chriszf/2342247 to your computer and use it in GitHub Desktop.
FizzBuzz without conditionals
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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