f | from itertools import compress | f | from itertools import compress |
| | | |
| def joinseq(*seq): | | def joinseq(*seq): |
t | seq_it = [iter(s) for s in seq] | t | seq = [iter(s) for s in seq] |
| letters = [next(it) for it in seq_it] | | tmp = [next(it) for it in seq] |
| tmp = list(compress(letters, [el != -1 for el in letters])) | | t = list(compress(tmp, [el != -1 for el in tmp])) |
| while len(tmp): | | while len(t): |
| min_val = min(tmp) | | m = min(t) |
| yield min_val | | yield m |
| idx = letters.index(min_val) | | idx = tmp.index(m) |
| letters[idx] = next(seq_it[idx], -1) | | tmp[idx] = next(seq[idx], -1) |
| tmp = list(compress(letters, [el != -1 for el in letters])) | | t = list(compress(tmp, [el != -1 for el in tmp])) |