h-index cleanups
This commit is contained in:
parent
d9393152c5
commit
6d523ad7c1
@ -383,35 +383,11 @@ def collect_min_jumps_from_board(board: list[int]) -> list[int]:
|
|||||||
return jumps + [len(board) - 1]
|
return jumps + [len(board) - 1]
|
||||||
|
|
||||||
|
|
||||||
def collect_scored_citations(citations: list[int]) -> list[int]:
|
|
||||||
return [
|
|
||||||
i for i, v in enumerate(list(sorted(citations, reverse=True))) if v >= (i + 1)
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def collect_h_index_qualified_citations(citations: list[int]) -> set[int]:
|
|
||||||
census: dict[int, int] = collect_h_index_census_from_citations(citations)
|
|
||||||
return {k for k, v in census.items() if v >= k}
|
|
||||||
|
|
||||||
|
|
||||||
def collect_h_index_census_from_citations(citations: list[int]) -> dict[int, int]:
|
|
||||||
census: dict[int, int] = {}
|
|
||||||
|
|
||||||
for n in set(citations):
|
|
||||||
census.setdefault(n, 0)
|
|
||||||
|
|
||||||
for paper in citations:
|
|
||||||
if paper >= n:
|
|
||||||
census[n] += 1
|
|
||||||
|
|
||||||
return census
|
|
||||||
|
|
||||||
|
|
||||||
def h_index(citations: list[int]) -> int:
|
def h_index(citations: list[int]) -> int:
|
||||||
last_qualified = None
|
last_qualified = None
|
||||||
|
|
||||||
for i, citation in enumerate(list(sorted(citations, reverse=True))):
|
for i, citation_count in enumerate(list(sorted(citations, reverse=True))):
|
||||||
if citation >= i + 1:
|
if citation_count >= i + 1:
|
||||||
last_qualified = i + 1
|
last_qualified = i + 1
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user