Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
13
Task/FizzBuzz/Python/fizzbuzz-9.py
Normal file
13
Task/FizzBuzz/Python/fizzbuzz-9.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
from itertools import cycle, izip, count, islice
|
||||
|
||||
fizzes = cycle([""] * 2 + ["Fizz"])
|
||||
buzzes = cycle([""] * 4 + ["Buzz"])
|
||||
both = (f + b for f, b in izip(fizzes, buzzes))
|
||||
|
||||
# if the string is "", yield the number
|
||||
# otherwise yield the string
|
||||
fizzbuzz = (word or n for word, n in izip(both, count(1)))
|
||||
|
||||
# print the first 100
|
||||
for i in islice(fizzbuzz, 100):
|
||||
print i
|
||||
Loading…
Add table
Add a link
Reference in a new issue