Created
February 28, 2019 12:05
-
-
Save xfenix/40706180b549546e84614ce47321fc89 to your computer and use it in GitHub Desktop.
Another fizz buzz version
This file contains 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
from functools import reduce | |
def reducer(acc, number): | |
local_buf = [] | |
local_buf.append('Fizz' if number % 3 == 0 else '') | |
local_buf.append('Buzz' if number % 5 == 0 else '') | |
acc.append(''.join(local_buf) or str(number)) | |
return acc | |
def fizz_buzz_me(size): | |
return "\n".join(reduce(reducer, range(1, size + 1), [])) | |
print(fizz_buzz_me(100)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment