Last active
December 10, 2015 22:49
-
-
Save ehermes/4505394 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def listbuzz(stop): | |
| for number in range(1,stop+1): | |
| out = [] | |
| if (number % 3) == 0: out.append('Fizz') | |
| if (number % 5) == 0: out.append('Buzz') | |
| output = ''.join(out) if len(out) else number | |
| return | |
| def stringbuzz(stop): | |
| for number in range(1,stop+1): | |
| out = '' | |
| if (number % 3) == 0: out += 'Fizz' | |
| if (number % 3) == 0: out += 'Buzz' | |
| output = out if len(out) else number | |
| return | |
| In [19]: time listbuzz(1000000) | |
| CPU times: user 0.56 s, sys: 0.04 s, total: 0.60 s | |
| Wall time: 0.60 s | |
| In [20]: time listbuzz(1000000) | |
| CPU times: user 0.58 s, sys: 0.03 s, total: 0.60 s | |
| Wall time: 0.61 s | |
| In [21]: time listbuzz(1000000) | |
| CPU times: user 0.58 s, sys: 0.02 s, total: 0.60 s | |
| Wall time: 0.60 s | |
| In [22]: time listbuzz(1000000) | |
| CPU times: user 0.58 s, sys: 0.02 s, total: 0.60 s | |
| Wall time: 0.61 s | |
| In [23]: time stringbuzz(1000000) | |
| CPU times: user 0.40 s, sys: 0.03 s, total: 0.44 s | |
| Wall time: 0.44 s | |
| In [24]: time stringbuzz(1000000) | |
| CPU times: user 0.42 s, sys: 0.02 s, total: 0.43 s | |
| Wall time: 0.43 s | |
| In [25]: time stringbuzz(1000000) | |
| CPU times: user 0.42 s, sys: 0.01 s, total: 0.43 s | |
| Wall time: 0.43 s | |
| In [26]: time stringbuzz(1000000) | |
| CPU times: user 0.41 s, sys: 0.02 s, total: 0.43 s | |
| Wall time: 0.43 s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment