Skip to content

Instantly share code, notes, and snippets.

@davesque
Created November 10, 2014 22:05
Show Gist options
  • Save davesque/7558a7aa97474fa2d577 to your computer and use it in GitHub Desktop.
Save davesque/7558a7aa97474fa2d577 to your computer and use it in GitHub Desktop.
Favorite python fizzbuzz implementation
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