{"record":{"id":"dca1888813263a70","repo":"rohitg00/ai-engineering-from-scratch","slug":"n-c-0-and-k-0","errorCode":null,"errorMessage":"n, c >= 0 and k > 0","messagePattern":"n, c >= 0 and k > 0","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"phases/19-capstone-projects/72-code-exec-metric/code/main.py","lineNumber":255,"sourceCode":"    if exit_code not in EXIT_CODES:\n        exit_code = EXIT_ERROR\n    if exit_code == EXIT_PASS and passed < total:\n        exit_code = EXIT_ASSERTION_FAIL\n    if exit_code == EXIT_ASSERTION_FAIL and passed == total and total > 0:\n        exit_code = EXIT_PASS\n    return ExecResult(score, exit_code, passed, total, detail=detail, per_assertion=results)\n\n\ndef score_code_exec(prediction: str, assertions: list[str], timeout_s: float = DEFAULT_TIMEOUT_S) -> float:\n    code = extract_code(prediction)\n    if code is None:\n        return 0.0\n    return run_candidate(code, assertions, timeout_s=timeout_s).score\n\n\ndef pass_at_k(n: int, c: int, k: int) -> float:\n    if n < 0 or c < 0 or k <= 0:\n        raise ValueError(\"n, c >= 0 and k > 0\")\n    if c > n:\n        raise ValueError(\"c cannot exceed n\")\n    if k > n:\n        return float(c > 0)\n    if n - c < k:\n        return 1.0\n    log_prob = 0.0\n    for i in range(k):\n        log_prob += math.log(n - c - i) - math.log(n - i)\n    return float(1.0 - math.exp(log_prob))\n\n\ndef pass_at_k_estimator(samples: list[list[bool]], ks: list[int]) -> dict[int, float]:\n    out: dict[int, float] = {}\n    for k in ks:\n        per_task = []\n        for sample in samples:\n            n = len(sample)","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/phases/19-capstone-projects/72-code-exec-metric/code/main.py#L237-L273","documentation":"Error \"n, c >= 0 and k > 0\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at phases/19-capstone-projects/72-code-exec-metric/code/main.py:255 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","schemaVersion":2},"datasetVersion":"2026-08-26T07:17:17.940Z"}