Compare commits
2 Commits
2f3ce704b2
...
6d523ad7c1
Author | SHA1 | Date | |
---|---|---|---|
6d523ad7c1 | |||
d9393152c5 |
@ -381,3 +381,15 @@ def collect_min_jumps_from_board(board: list[int]) -> list[int]:
|
|||||||
range_end = range_begin + val + 1
|
range_end = range_begin + val + 1
|
||||||
|
|
||||||
return jumps + [len(board) - 1]
|
return jumps + [len(board) - 1]
|
||||||
|
|
||||||
|
|
||||||
|
def h_index(citations: list[int]) -> int:
|
||||||
|
last_qualified = None
|
||||||
|
|
||||||
|
for i, citation_count in enumerate(list(sorted(citations, reverse=True))):
|
||||||
|
if citation_count >= i + 1:
|
||||||
|
last_qualified = i + 1
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
|
||||||
|
return last_qualified or 0
|
||||||
|
@ -310,3 +310,24 @@ def test_collect_complete_jump_paths_from_board(
|
|||||||
)
|
)
|
||||||
def test_count_min_jumps_from_board(board: list[int], expected: int):
|
def test_count_min_jumps_from_board(board: list[int], expected: int):
|
||||||
assert stuff.count_min_jumps_from_board(board) == expected
|
assert stuff.count_min_jumps_from_board(board) == expected
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
("citations", "expected"),
|
||||||
|
[
|
||||||
|
(
|
||||||
|
[3, 0, 6, 1, 5],
|
||||||
|
3,
|
||||||
|
),
|
||||||
|
(
|
||||||
|
[1, 3, 1],
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
(
|
||||||
|
[100],
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_h_index(citations: list[int], expected: int):
|
||||||
|
assert stuff.h_index(citations) == expected
|
||||||
|
Loading…
Reference in New Issue
Block a user