Тишина Ульяна Кирилловна, 411 SeeSaw 9346 | Парыгина Дарья, 627 группа SeeSaw 9401 | ||||
---|---|---|---|---|---|
f | 1 | from itertools import tee, zip_longest | f | 1 | from itertools import tee, zip_longest |
2 | 2 | ||||
t | 3 | def seesaw(seq): | t | 3 | def seesaw(sequence): |
4 | a, b = tee(seq, 2) | 4 | it1, it2 = tee(sequence, 2) | ||
5 | a = (x for x in a if x % 2 == 0) | 5 | it1 = (x for x in it1 if x % 2 == 0) | ||
6 | b = (x for x in b if x % 2 == 1) | 6 | it2 = (x for x in it2 if x % 2 == 1) | ||
7 | for x, y in zip_longest(a, b, fillvalue=None): | 7 | for a, b in zip_longest(it1, it2, fillvalue=None): | ||
8 | if x != None: | 8 | if a is not None: | ||
9 | yield x | 9 | yield a | ||
10 | if y != None: | 10 | if b is not None: | ||
11 | yield y | 11 | yield b |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|