Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Since we are talking about crazy python fizzbuzz, allow me to share a creating I have had sitting around for a while:

    def fbg(s,r):print("\n".join(map(lambda x:str(x[1])if x[0]==''else x[0],zip(("".join(a for a,b in s if n%b==0)for n in range(1,r+1)),range(1,r+1)))))
    fbg((('Fizz',3),('Buzz',5)),100)
Cause, you know, fizzbuzz one-liners need to work for the generic case.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: