"""
Practice: decide when the assistant should hand an answer to a person, the way Lab 18's script 02
does. Each answer has a risk from a warning sign (higher = more likely wrong) and, for testing, a
grade from the answer key. You'll score how well a sign ranks the answers that needed a person,
draw the line that keeps the AI's own answers under an error rate, and count how sure it was.

Fill in the TODOs, then run the tests:
    pytest test_selfcheck_practice.py        (locally)
or press "Run tests" on the chapter page.
"""


def needs_person(grade: str) -> bool:
    """grade is "correct", "wrong" or "refused" (said "I don't know" though the articles had the
    answer). A person should have handled the wrong answers and the wrong refusals."""
    # TODO
    raise NotImplementedError


def ranking_score(risks: list[float], bad: list[bool]) -> float:
    """The share of (bad, fine) pairs where the bad answer has the higher risk. A tie counts as
    half. 1.0 = every bad answer looks riskier than every fine one; 0.5 = a coin flip.
    (This is AUROC, the area under the ROC curve.)"""
    # TODO
    raise NotImplementedError


def escalation_curve(risks: list[float], bad: list[bool]) -> list[tuple[float, float, int]]:
    """Line the answers up riskiest first (equal risks keep their original order). For every place
    the line can go, return (share sent to a person, error rate of the rest, bad answers left).
    Equal risks go to a person together, so the line can't split a tie. Start with sending
    nothing (0.0, ...) and end with sending everything (1.0, 0.0, 0)."""
    # TODO
    raise NotImplementedError


def escalate_for(risks: list[float], bad: list[bool], max_error: float) -> tuple[float, int]:
    """The smallest share to send to a person so that, of the answers the AI sends on its own,
    at most max_error need a person. Return (share, bad answers left)."""
    # TODO
    raise NotImplementedError


def very_sure(sure: list[int], grades: list[str], at: int = 90) -> dict[str, tuple[int, int]]:
    """sure: how sure the checker said it was, 0-100, for each answer. For each grade, return
    (how many it was at least `at` sure of, how many there are)."""
    # TODO
    raise NotImplementedError
