A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
19
Task/Generator-Exponential/Python/generator-exponential.py
Normal file
19
Task/Generator-Exponential/Python/generator-exponential.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
from itertools import islice, count
|
||||
|
||||
def powers(m):
|
||||
for n in count():
|
||||
yield n ** m
|
||||
|
||||
def filtered(s1, s2):
|
||||
v, f = next(s1), next(s2)
|
||||
while True:
|
||||
if v > f:
|
||||
f = next(s2)
|
||||
continue
|
||||
elif v < f:
|
||||
yield v
|
||||
v = next(s1)
|
||||
|
||||
squares, cubes = powers(2), powers(3)
|
||||
f = filtered(squares, cubes)
|
||||
print(list(islice(f, 20, 30)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue