Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,7 +1 @@
|
|||
for n in range(1,101):
|
||||
msg = ""
|
||||
if not (n%3):
|
||||
msg += "Fizz"
|
||||
if not (n%5):
|
||||
msg += "Buzz"
|
||||
print msg or str(n)
|
||||
for i in range(1,101): print("Fizz"*(i%3==0) + "Buzz"*(i%5==0) or i)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,13 @@
|
|||
for i in range(1, 101):
|
||||
words = [word for n, word in ((3, 'Fizz'), (5, 'Buzz')) if not i % n]
|
||||
print ''.join(words) or i
|
||||
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