Created
November 10, 2014 22:05
-
-
Save davesque/7558a7aa97474fa2d577 to your computer and use it in GitHub Desktop.
Favorite python fizzbuzz implementation
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
def d(fn): | |
def fn_(*args): | |
print fn(*args) | |
return fn_ | |
fs = { | |
(False, True): d(lambda _: 'fizz'), | |
(True, False): d(lambda _: 'buzz'), | |
(False, False): d(lambda _: 'fizzbuzz'), | |
(True, True): d(str), | |
} | |
[fs[bool(i % 3), bool(i % 5)](i) for i in range(1, 101)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment