Data update
This commit is contained in:
parent
72eb4943cb
commit
4d5544505c
2347 changed files with 62432 additions and 16731 deletions
|
|
@ -1,33 +1,13 @@
|
|||
'''Fizz buzz'''
|
||||
from itertools import cycle, izip, count, islice
|
||||
|
||||
from itertools import count, cycle, 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)))
|
||||
|
||||
# fizzBuzz :: () -> Generator [String]
|
||||
def fizzBuzz():
|
||||
'''A non-finite stream of fizzbuzz terms.
|
||||
'''
|
||||
return map(
|
||||
lambda f, b, n: (f + b) or str(n),
|
||||
cycle([''] * 2 + ['Fizz']),
|
||||
cycle([''] * 4 + ['Buzz']),
|
||||
count(1)
|
||||
)
|
||||
|
||||
|
||||
# ------------------------- TEST -------------------------
|
||||
def main():
|
||||
'''Display of first 100 terms of the fizzbuzz series.
|
||||
'''
|
||||
print(
|
||||
'\n'.join(
|
||||
list(islice(
|
||||
fizzBuzz(),
|
||||
100
|
||||
))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
# print the first 100
|
||||
for i in islice(fizzbuzz, 100):
|
||||
print i
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue