Skip to content

Instantly share code, notes, and snippets.

@code-R
Last active August 21, 2018 12:42
Show Gist options
  • Save code-R/f7c5b1ce4e2c98cf174ccb3e8193f425 to your computer and use it in GitHub Desktop.
Save code-R/f7c5b1ce4e2c98cf174ccb3e8193f425 to your computer and use it in GitHub Desktop.
fizzbuzz
class FizzBuzzGenerator(object):
"""docstring for Generator."""
fizz_mapper = {
3: "fizz",
5: "buzz",
7: "fooo",
}
def __init__(self, count=5):
self.count = count + 1
def fizz_buzz(self, input):
res = []
for k, v in self.fizz_mapper.items():
if input % k == 0:
res.append(v)
output = " ".join(res)
return output or input
def run(self):
return (self.fizz_buzz(x) for x in xrange(1, self.count))
fbg = FizzBuzzGenerator(105)
for i in fbg.run():
print(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment