diff options
Diffstat (limited to 'src/util/range.py')
-rw-r--r-- | src/util/range.py | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/src/util/range.py b/src/util/range.py deleted file mode 100644 index bd4b27e..0000000 --- a/src/util/range.py +++ /dev/null @@ -1,30 +0,0 @@ -from typing import NamedTuple, List - -class Range(NamedTuple): - start: int - length: int - -def from_indexes(indexes: List[int]) -> List[Range]: - ranges = [] - curr_range_start = 0 - curr_range_len = 0 - - last_index = -1 - - for index in sorted(indexes): - if index == curr_range_start + curr_range_len: - curr_range_len += 1 - else: - if curr_range_len > 0: - ranges.append(Range( - start = curr_range_start, - length = curr_range_len)) - curr_range_start = index - curr_range_len = 1 - - if curr_range_len > 0: - ranges.append(Range( - start = curr_range_start, - length = curr_range_len)) - - return ranges |