4 ms·
I had a bunch of fun coming up with terrible ways to write FizzBuzz a little while back. My favorites, in Python https://gist.github.com/daeken/1e3c680c20da98c
by daeken 14y ago
I had a bunch of fun coming up with terrible ways to write FizzBuzz a little while back. My favorites, in Python https://gist.github.com/daeken/1e3c680c20da98c680c4 https://gist.github.com/daeken/1e3c680c20da98c680c4 and C https://gist.github.com/daeken/15769d83b66974335f78 https://gist.github.com/daeken/15769d83b66974335f78
- pcote 14y ago# That inspired me to have a bit of my own fun. Here's my awful Python take on it. [(n, (lambda x: ("fizz" if x % 3 == 0 else "") + ("buzz" if x % 5 == 0 else ""))(n)) for n in range(1,51)]
- Goopplesoft 14y agoThat python code made me cringe. decorators, parsing, compiling and evals? You win.
- reinhardt 14y agoNo metaclasses or descriptors though, still needs some work.
- pcote 14y agoOh, you want metaclasses? How about this? print(type("",(),{"__call__": lambda self, start, end: [(n, (lambda x: ("fizz" if x % 3 == 0 else "") + ("buzz" if x % 5 == 0 else ""))(n)) for n in range(start,end+1)] })()(1,50))
- shuzchen 14y agoHere's my python version that uses the y-combinator: https://gist.github.com/sirpengi/3443999 https://gist.github.com/sirpengi/3443999