Created
March 30, 2020 18:21
-
-
Save slykar/565b158e53753c340a13245a6034f396 to your computer and use it in GitHub Desktop.
Declarative FizzBuzz in Python
This file contains hidden or 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
FROM = 1 | |
TO = 100 | |
DIVIDERS = [ | |
(3, "Fizz"), | |
(5, "Buzz"), | |
(7, "Kazz") # or any other (div, word) pair | |
] | |
for n in range(FROM, TO): | |
output_words = [word for div, word in DIVIDERS if n % div == 0] | |
print(''.join(output_words) if output_words else n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment