Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
9
Task/FizzBuzz/Python/fizzbuzz-1.py
Normal file
9
Task/FizzBuzz/Python/fizzbuzz-1.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
for i in xrange(1, 101):
|
||||
if i % 15 == 0:
|
||||
print "FizzBuzz"
|
||||
elif i % 3 == 0:
|
||||
print "Fizz"
|
||||
elif i % 5 == 0:
|
||||
print "Buzz"
|
||||
else:
|
||||
print i
|
||||
33
Task/FizzBuzz/Python/fizzbuzz-10.py
Normal file
33
Task/FizzBuzz/Python/fizzbuzz-10.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
'''Fizz buzz'''
|
||||
|
||||
from itertools import count, cycle, islice
|
||||
|
||||
|
||||
# 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()
|
||||
1
Task/FizzBuzz/Python/fizzbuzz-11.py
Normal file
1
Task/FizzBuzz/Python/fizzbuzz-11.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
print(*map(lambda n: 'Fizzbuzz '[(i):i+13] if (i := n**4%-15) > -14 else n, range(1,100)))
|
||||
12
Task/FizzBuzz/Python/fizzbuzz-12.py
Normal file
12
Task/FizzBuzz/Python/fizzbuzz-12.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
def numsum(n):
|
||||
''' The recursive sum of all digits in a number
|
||||
unit a single character is obtained'''
|
||||
res = sum([int(i) for i in str(n)])
|
||||
if res < 10: return res
|
||||
else : return numsum(res)
|
||||
|
||||
for n in range(1,101):
|
||||
response = 'Fizz'*(numsum(n) in [3,6,9]) + \
|
||||
'Buzz'*(str(n)[-1] in ['5','0'])\
|
||||
or n
|
||||
print(response)
|
||||
1
Task/FizzBuzz/Python/fizzbuzz-13.py
Normal file
1
Task/FizzBuzz/Python/fizzbuzz-13.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
print(*((lambda x=x: ''.join(chr(c) for c in (102, 105)) + (2 * chr(122)) + ''.join(chr(c) for c in (98, 117)) + (2 * chr(122)) + '\n' if x % (30 >> 1) == 0 else ''.join(chr(c) for c in (102, 105)) + (2 * chr(122)) + '\n' if x % (6 >> 1) == 0 else ''.join(chr(c) for c in (98, 117)) + (2 * chr(122)) + '\n' if x % (10 >> 1) == 0 else str(x) + '\n')() for x in range(1, 101)))
|
||||
9
Task/FizzBuzz/Python/fizzbuzz-2.py
Normal file
9
Task/FizzBuzz/Python/fizzbuzz-2.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
for i in range(1, 101):
|
||||
if i % 15 == 0:
|
||||
print("FizzBuzz")
|
||||
elif i % 3 == 0:
|
||||
print("Fizz")
|
||||
elif i % 5 == 0:
|
||||
print("Buzz")
|
||||
else:
|
||||
print(i)
|
||||
9
Task/FizzBuzz/Python/fizzbuzz-3.py
Normal file
9
Task/FizzBuzz/Python/fizzbuzz-3.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
for n in range(1,101):
|
||||
response = ''
|
||||
|
||||
if not n%3:
|
||||
response += 'Fizz'
|
||||
if not n%5:
|
||||
response += 'Buzz'
|
||||
|
||||
print(response or n)
|
||||
1
Task/FizzBuzz/Python/fizzbuzz-4.py
Normal file
1
Task/FizzBuzz/Python/fizzbuzz-4.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
for i in range(1,101): print("Fizz"*(i%3==0) + "Buzz"*(i%5==0) or i)
|
||||
1
Task/FizzBuzz/Python/fizzbuzz-5.py
Normal file
1
Task/FizzBuzz/Python/fizzbuzz-5.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
for i in range(100):print(i%3//2*'Fizz'+i%5//4*'Buzz'or i+1)
|
||||
3
Task/FizzBuzz/Python/fizzbuzz-6.py
Normal file
3
Task/FizzBuzz/Python/fizzbuzz-6.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
for n in range(1, 100):
|
||||
fb = ''.join([ denom[1] if n % denom[0] == 0 else '' for denom in [(3,'fizz'),(5,'buzz')] ])
|
||||
print fb if fb else n
|
||||
1
Task/FizzBuzz/Python/fizzbuzz-7.py
Normal file
1
Task/FizzBuzz/Python/fizzbuzz-7.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
print (', '.join([(x%3<1)*'Fizz'+(x%5<1)*'Buzz' or str(x) for x in range(1,101)]))
|
||||
1
Task/FizzBuzz/Python/fizzbuzz-8.py
Normal file
1
Task/FizzBuzz/Python/fizzbuzz-8.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
[print("FizzBuzz") if i % 15 == 0 else print("Fizz") if i % 3 == 0 else print("Buzz") if i % 5 == 0 else print(i) for i in range(1,101)]
|
||||
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