Мельников Алексей, Севастополь SeqJoin 9389
Stanislav SeqJoin 9850
f1def joinseq(*sequences):f1def joinseq(*sequences):
2    iterators = [iter(seq) for seq in sequences]2    iterators = [iter(seq) for seq in sequences]
3    iterators_count = len(iterators)3    iterators_count = len(iterators)
4    iterator_array = [None] * iterators_count4    iterator_array = [None] * iterators_count
n5    for i, iterator in enumerate(iterators):n5    for i, it in enumerate(iterators):
6        element = next(iterator, None)6        el = next(it, None)
7        if element is not None:7        if el is not None:
8            iterator_array[i] = element8            iterator_array[i] = el
9        else:9        else:
10            iterator_array[i] = None10            iterator_array[i] = None
11            iterators_count -= 111            iterators_count -= 1
12    while iterators_count > 0:12    while iterators_count > 0:
13        min_index = None13        min_index = None
14        min_value = None14        min_value = None
n15        for i, el in enumerate(iterator_array):n15        for i, val in enumerate(iterator_array):
16            if el is None:16            if val is None:
17                continue17                continue
n18            if min_value is None or el < min_value:n18            if min_value is None or val < min_value:
19                min_value = el19                min_value = val
20                min_index = i20                min_index = i
21        if min_index is not None:21        if min_index is not None:
22            yield min_value22            yield min_value
t23            element = next(iterators[min_index], None)t23            el = next(iterators[min_index], None)
24            if element is not None:24            if el is not None:
25                iterator_array[min_index] = element25                iterator_array[min_index] = el
26            else:26            else:
27                iterator_array[min_index] = None27                iterator_array[min_index] = None
28                iterators_count -= 128                iterators_count -= 1
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op