Skip to content

Instantly share code, notes, and snippets.

@xfenix
Created February 28, 2019 12:05
Show Gist options
  • Save xfenix/40706180b549546e84614ce47321fc89 to your computer and use it in GitHub Desktop.
Save xfenix/40706180b549546e84614ce47321fc89 to your computer and use it in GitHub Desktop.
Another fizz buzz version
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