Created
March 12, 2019 12:18
-
-
Save cristianrasch/5701660ed523b98d9f51c4cb97134ee0 to your computer and use it in GitHub Desktop.
This file contains 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
from itertools import cycle, chain, islice, repeat | |
fizzes = cycle(chain(islice(repeat(''), 2), ('fizz' for _ in range(1)))) | |
buzzes = cycle(chain(islice(repeat(''), 4), ('buzz' for _ in range(1)))) | |
fizzes_buzzes = zip(range(1, 101), fizzes, buzzes) | |
fizz_buzz = (str(i) if not(fizz) and not(buzz) else f'{fizz}{buzz}' for i, fizz, buzz in fizzes_buzzes) | |
for line in fizz_buzz: | |
print(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment