Last active
August 23, 2022 17:22
-
-
Save pathunstrom/4eff1ea856eb0480d3c08b49e0408393 to your computer and use it in GitHub Desktop.
Sample Fizz Buzzes
This file contains hidden or 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 fizzbuzz_generator(): | |
value = yield | |
while True: | |
rv = "" | |
if not value % 3: | |
rv += "Fizz" | |
if not value % 5: | |
rv += "Buzz" | |
value = yield rv or value | |
def fizzbuzz(): | |
cfb = fizzbuzz_generator() | |
next(cfb) | |
for x in range(101): | |
print(cfb.send(x)) |
This file contains hidden or 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
__author__ = "palindromordnilap" | |
print('1') | |
print('2') | |
print('Fizz') | |
print('4') | |
print('Buzz') | |
print('Fizz') | |
print('7') | |
print('8') | |
print('Fizz') | |
print('Buzz') | |
print('11') | |
print('Fizz') | |
print('13') | |
print('14') | |
print('FizzBuzz') | |
print('16') | |
print('17') | |
print('Fizz') | |
print('19') | |
print('Buzz') | |
print('Fizz') | |
print('22') | |
print('23') | |
print('Fizz') | |
print('Buzz') | |
print('26') | |
print('Fizz') | |
print('28') | |
print('29') | |
print('FizzBuzz') | |
print('31') | |
print('32') | |
print('Fizz') | |
print('34') | |
print('Buzz') | |
print('Fizz') | |
print('37') | |
print('38') | |
print('Fizz') | |
print('Buzz') | |
print('41') | |
print('Fizz') | |
print('43') | |
print('44') | |
print('FizzBuzz') | |
print('46') | |
print('47') | |
print('Fizz') | |
print('49') | |
print('Buzz') | |
print('Fizz') | |
print('52') | |
print('53') | |
print('Fizz') | |
print('Buzz') | |
print('56') | |
print('Fizz') | |
print('58') | |
print('59') | |
print('FizzBuzz') | |
print('61') | |
print('62') | |
print('Fizz') | |
print('64') | |
print('Buzz') | |
print('Fizz') | |
print('67') | |
print('68') | |
print('Fizz') | |
print('Buzz') | |
print('71') | |
print('Fizz') | |
print('73') | |
print('74') | |
print('FizzBuzz') | |
print('76') | |
print('77') | |
print('Fizz') | |
print('79') | |
print('Buzz') | |
print('Fizz') | |
print('82') | |
print('83') | |
print('Fizz') | |
print('Buzz') | |
print('86') | |
print('Fizz') | |
print('88') | |
print('89') | |
print('FizzBuzz') | |
print('91') | |
print('92') | |
print('Fizz') | |
print('94') | |
print('Buzz') | |
print('Fizz') | |
print('97') | |
print('98') | |
print('Fizz') | |
print('Buzz') |
This file contains hidden or 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 fizzbuzz(): | |
for i in range(1, 101): | |
print_val = "" | |
if not i % 3: | |
print_val += "Fizz" | |
if not i % 5: | |
print_val += "Buzz" | |
print(print_val or i) |
This file contains hidden or 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
"""F-string powered fizzbuzz""" | |
for n in range(1, 101): | |
print(f"{'fizz' if not n % 3 else ''}{'buzz' if not n % 5 else ''}" or n) |
This file contains hidden or 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 fizzbuzz(n): | |
fizz = lambda f: (lambda x: "Fizz" + f("")) if n % 3 == 0 else f | |
buzz = lambda f: (lambda x: "Buzz" + f("")) if n % 5 == 0 else f | |
identity = lambda s: s | |
return fizz(buzz(identity))(str(n)) | |
for i in range(1,101): | |
print(fizzbuzz(i)) |
This file contains hidden or 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 fizzbuzz(): | |
for i in range(1, 101): | |
if not i % 15: | |
print("FizzBuzz") | |
elif not i % 5: | |
print("Buzz") | |
elif not i % 3: | |
print("Fizz") | |
else: | |
print(i) |
This file contains hidden or 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 fizzbuzz(n): | |
out = "" | |
if not n-3*(n//3): out += "Fizz" | |
if not n-5*(n//5): out += "Buzz" | |
return out or n |
This file contains hidden or 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 fizzbuzz(length): | |
if not length: | |
return | |
else: | |
fizzbuzz(length - 1) | |
print_val = "" | |
if not length % 3: | |
print_val += "Fizz" | |
if not length % 5: | |
print_val += "Buzz" | |
print(print_val or length) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment