Skip to content

Instantly share code, notes, and snippets.

@kbob
Created January 2, 2020 02:27
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 kbob/f46776fdc950e6a948b04c76bc23e874 to your computer and use it in GitHub Desktop.
Save kbob/f46776fdc950e6a948b04c76bc23e874 to your computer and use it in GitHub Desktop.
Yet Another FizzBuzz
#!/usr/bin/env python3
from functools import reduce
from itertools import count, cycle, islice, repeat
def fizzbuzz(*args):
class Fizz(int):
__add__ = lambda fi, z: z
__call__ = lambda b, u, z: z(u)
Buzz = print
f = lambda f: f + 'Fizz'
b = lambda b: b + 'Buzz'
F = i = z = z = lambda z: z
B = u = z = z = lambda z: z
if (Fizz or Buzz): {
reduce(Fizz(i == z), z)
for z in islice(zip(count(),
repeat(Fizz),
cycle((f, i, z)),
cycle((b, u, z, z, z)),
repeat(Buzz)),
*args)
}
fizzbuzz(1, 100 + 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment