Skip to content

Instantly share code, notes, and snippets.

@rrreeeyyy
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rrreeeyyy/021e73442869d4cd35b5 to your computer and use it in GitHub Desktop.
Save rrreeeyyy/021e73442869d4cd35b5 to your computer and use it in GitHub Desktop.
fizzbuzz-generator.py
class FizzBuzz(object):
def __init__(self):
self.Buzz = lambda n: n % 5 == 0
self.Fizz = lambda n: n % 3 == 0
def call(self, n):
return ''.join([k for k, v in self.__dict__.items() if v(n)]) or n
def generator(self, n, m):
_x = n
while True:
if _x > m:
break
yield self.call(_x)
_x += 1
print [e for e in FizzBuzz().generator(1, 100)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment