Skip to content

Instantly share code, notes, and snippets.

@podhmo
Created October 16, 2016 17:24
Show Gist options
  • Save podhmo/d7db336767b57fe9d249c80f88356405 to your computer and use it in GitHub Desktop.
Save podhmo/d7db336767b57fe9d249c80f88356405 to your computer and use it in GitHub Desktop.
import itertools
def fizzbuzz(begin, end):
xs = [lambda i: print(i) for _ in range(15)]
xs[3 - 1] = lambda i: print("fizz")
xs[5 - 1] = lambda i: print("buzz")
xs[15 - 1] = lambda i: print("fizzbuzz")
it = itertools.cycle(xs)
for i in range(begin, end + 1):
next(it)(i)
if __name__ == "__main__":
fizzbuzz(1, 100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment