Stanislav SeqJoin 9850
Мельников Алексей, Севастополь SeqJoin 9389
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, it in enumerate(iterators):n5    for i, iterator in enumerate(iterators):
6        el = next(it, None)6        element = next(iterator, None)
7        if el is not None:7        if element is not None:
8            iterator_array[i] = el8            iterator_array[i] = element
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, val in enumerate(iterator_array):n15        for i, el in enumerate(iterator_array):
16            if val is None:16            if el is None:
17                continue17                continue
n18            if min_value is None or val < min_value:n18            if min_value is None or el < min_value:
19                min_value = val19                min_value = el
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            el = next(iterators[min_index], None)t23            element = next(iterators[min_index], None)
24            if el is not None:24            if element is not None:
25                iterator_array[min_index] = el25                iterator_array[min_index] = element
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