aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorJoris2020-06-06 17:44:26 +0200
committerJoris2020-06-06 19:54:03 +0200
commit1595e0de940a86a7810df0e02e43838d97c0d846 (patch)
tree9701eeec0d98baa9f6044b1911df68e4c8539819 /src/util
parent6b9195000eb5404c247288b384d7ca2bacc1ab23 (diff)
Provide nix build
Diffstat (limited to 'src/util')
-rw-r--r--src/util/array.py5
-rw-r--r--src/util/range.py30
-rw-r--r--src/util/test_array.py12
-rw-r--r--src/util/test_range.py6
4 files changed, 0 insertions, 53 deletions
diff --git a/src/util/array.py b/src/util/array.py
deleted file mode 100644
index bb4eee3..0000000
--- a/src/util/array.py
+++ /dev/null
@@ -1,5 +0,0 @@
-def insert_position(x, xs, is_reversed: bool) -> int:
- for i, y in enumerate(xs):
- if is_reversed and x >= y or not is_reversed and x <= y:
- return i
- return len(xs)
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
diff --git a/src/util/test_array.py b/src/util/test_array.py
deleted file mode 100644
index 38759b9..0000000
--- a/src/util/test_array.py
+++ /dev/null
@@ -1,12 +0,0 @@
-from array import insert_position
-
-def test_insert_position():
- assert insert_position(0, [], False) == 0
- assert insert_position(1, [1, 2, 3], False) == 0
- assert insert_position(2, [1, 2, 3], False) == 1
- assert insert_position(3, [1, 2, 3], False) == 2
- assert insert_position(8, [1, 2, 3], False) == 3
- assert insert_position(8, [3, 2, 1], True) == 0
- assert insert_position(3, [3, 2, 1], True) == 0
- assert insert_position(2, [3, 2, 1], True) == 1
- assert insert_position(1, [3, 2, 1], True) == 2
diff --git a/src/util/test_range.py b/src/util/test_range.py
deleted file mode 100644
index 0bd909b..0000000
--- a/src/util/test_range.py
+++ /dev/null
@@ -1,6 +0,0 @@
-from range import from_indexes, Range
-
-def test_from_indexes():
- assert from_indexes([]) == []
- assert from_indexes([1]) == [Range(1, 1)]
- assert from_indexes([9, 6, 0, 10]) == [Range(0, 1), Range(6, 1), Range(9, 2)]