|
|
|
@ -331,3 +331,29 @@ def test_count_min_jumps_from_board(board: list[int], expected: int):
|
|
|
|
|
)
|
|
|
|
|
def test_h_index(citations: list[int], expected: int):
|
|
|
|
|
assert stuff.h_index(citations) == expected
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_randomized_set():
|
|
|
|
|
inst = stuff.RandomizedSet()
|
|
|
|
|
|
|
|
|
|
assert inst.insert(1) is True
|
|
|
|
|
assert inst.remove(2) is False
|
|
|
|
|
assert inst.insert(2) is True
|
|
|
|
|
assert inst.getRandom() in (1, 2)
|
|
|
|
|
assert inst.remove(1) is True
|
|
|
|
|
assert inst.insert(2) is False
|
|
|
|
|
assert inst.getRandom() == 2
|
|
|
|
|
|
|
|
|
|
inst = stuff.RandomizedSet()
|
|
|
|
|
|
|
|
|
|
assert inst.insert(1) is True
|
|
|
|
|
assert inst.insert(10) is True
|
|
|
|
|
assert inst.insert(20) is True
|
|
|
|
|
assert inst.insert(30) is True
|
|
|
|
|
|
|
|
|
|
seen: set[int] = set()
|
|
|
|
|
|
|
|
|
|
for _ in range(100_000):
|
|
|
|
|
seen.add(inst.getRandom())
|
|
|
|
|
|
|
|
|
|
assert seen == {1, 10, 20, 30}
|
|
|
|
|