blakeembrey / code-problems

Common code and interview problems solved in multiple languages
MIT License
3.81k stars 509 forks source link

Shorter shortest-fizz-buzz for Python{2,3} #181

Closed burz closed 7 years ago

burz commented 7 years ago

The solution for the shortest-fizz-buzz problem as it stands is not really that short at all even though that is the intended goal of the problem.

I propose the following as a solution. It works in both Python2 and Python3 and is significantly smaller (87 vs 305 characters).

This solution uses various tricks dependent on the way Python interprets code. In particular:

blakeembrey commented 7 years ago

Looks fantastic, nice job!