Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Generator-Exponential/Python/generator-exponential-1.py
Normal file
19
Task/Generator-Exponential/Python/generator-exponential-1.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