September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
1
Task/FizzBuzz/Python/fizzbuzz-10.py
Normal file
1
Task/FizzBuzz/Python/fizzbuzz-10.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)))
|
||||
|
|
@ -1 +1,9 @@
|
|||
for i in range(1,101): print("Fizz"*(i%3==0) + "Buzz"*(i%5==0) or i)
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
for i in range(100):print(i%3//2*'Fizz'+i%5//4*'Buzz'or i+1)
|
||||
for i in range(1,101): print("Fizz"*(i%3==0) + "Buzz"*(i%5==0) or i)
|
||||
|
|
|
|||
|
|
@ -1,3 +1 @@
|
|||
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
|
||||
for i in range(100):print(i%3//2*'Fizz'+i%5//4*'Buzz'or i+1)
|
||||
|
|
|
|||
|
|
@ -1 +1,3 @@
|
|||
[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)]
|
||||
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,13 +1 @@
|
|||
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
|
||||
print (', '.join([(x%3<1)*'Fizz'+(x%5<1)*'Buzz' or str(x) for x in range(1,101)]))
|
||||
|
|
|
|||
1
Task/FizzBuzz/Python/fizzbuzz-7.py
Normal file
1
Task/FizzBuzz/Python/fizzbuzz-7.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-8.py
Normal file
13
Task/FizzBuzz/Python/fizzbuzz-8.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
|
||||
52
Task/FizzBuzz/Python/fizzbuzz-9.py
Normal file
52
Task/FizzBuzz/Python/fizzbuzz-9.py
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
'''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 n,
|
||||
cycle([''] * 2 + ['Fizz']),
|
||||
cycle([''] * 4 + ['Buzz']),
|
||||
map(str, count(1))
|
||||
)
|
||||
|
||||
|
||||
# main :: IO ()
|
||||
def main():
|
||||
'''Display of first 100 terms of the fizzbuzz series.
|
||||
'''
|
||||
print(unlines(
|
||||
take(100)(
|
||||
fizzBuzz()
|
||||
)
|
||||
))
|
||||
|
||||
|
||||
# GENERIC -------------------------------------------------
|
||||
|
||||
# take :: Int -> [a] -> [a]
|
||||
# take :: Int -> String -> String
|
||||
def take(n):
|
||||
'''The prefix of xs of length n,
|
||||
or xs itself if n > length xs.
|
||||
'''
|
||||
return lambda xs: (
|
||||
xs[0:n]
|
||||
if isinstance(xs, (list, tuple))
|
||||
else list(islice(xs, n))
|
||||
)
|
||||
|
||||
|
||||
# unlines :: [String] -> String
|
||||
def unlines(xs):
|
||||
'''A single string formed by the intercalation
|
||||
of a list of strings with the newline character.
|
||||
'''
|
||||
return '\n'.join(xs)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue