Пак Алиса, 611 группа SeeSaw 9540 | Всеволод Оплачко, 404 группа КФ SeeSaw 8813 | ||||
---|---|---|---|---|---|
f | 1 | def seesaw(sequence): | f | 1 | def seesaw(sequence): |
2 | evens = [] | 2 | evens = [] | ||
3 | odds = [] | 3 | odds = [] | ||
4 | for num in sequence: | 4 | for num in sequence: | ||
5 | if num % 2 == 0: | 5 | if num % 2 == 0: | ||
6 | evens.append(num) | 6 | evens.append(num) | ||
7 | else: | 7 | else: | ||
8 | odds.append(num) | 8 | odds.append(num) | ||
t | 9 | evens_idx = 0 | t | 9 | e_idx = 0 |
10 | odds_idx = 0 | 10 | o_idx = 0 | ||
11 | while evens_idx < len(evens) or odds_idx < len(odds): | 11 | while e_idx < len(evens) or o_idx < len(odds): | ||
12 | if evens_idx < len(evens): | 12 | if e_idx < len(evens): | ||
13 | yield evens[evens_idx] | 13 | yield evens[e_idx] | ||
14 | evens_idx += 1 | 14 | e_idx += 1 | ||
15 | if odds_idx < len(odds): | 15 | if o_idx < len(odds): | ||
16 | yield odds[odds_idx] | 16 | yield odds[o_idx] | ||
17 | odds_idx += 1 | 17 | o_idx += 1 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|