{"record":{"id":"04f526c893cbbcd2","repo":"TheAlgorithms/Python","slug":"scores-cannot-be-empty","errorCode":null,"errorMessage":"Scores cannot be empty","messagePattern":"Scores cannot be empty","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"backtracking/minimax.py","lineNumber":58,"sourceCode":"    65\n    >>> minimax(-1, 0, True, scores, height)\n    Traceback (most recent call last):\n        ...\n    ValueError: Depth cannot be less than 0\n    >>> minimax(0, 0, True, [], 2)\n    Traceback (most recent call last):\n        ...\n    ValueError: Scores cannot be empty\n    >>> scores = [3, 5, 2, 9, 12, 5, 23, 23]\n    >>> height = math.log(len(scores), 2)\n    >>> minimax(0, 0, True, scores, height)\n    12\n    \"\"\"\n\n    if depth < 0:\n        raise ValueError(\"Depth cannot be less than 0\")\n    if len(scores) == 0:\n        raise ValueError(\"Scores cannot be empty\")\n\n    # Base case: If the current depth equals the height of the tree,\n    # return the score of the current node.\n    if depth == height:\n        return scores[node_index]\n\n    # If it's the maximizer's turn, choose the maximum score\n    # between the two possible moves.\n    if is_max:\n        return max(\n            minimax(depth + 1, node_index * 2, False, scores, height),\n            minimax(depth + 1, node_index * 2 + 1, False, scores, height),\n        )\n\n    # If it's the minimizer's turn, choose the minimum score\n    # between the two possible moves.\n    return min(\n        minimax(depth + 1, node_index * 2, True, scores, height),","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/backtracking/minimax.py#L40-L76","documentation":"A defensive tail raise at the end of casimir_force() in physics/casimir_effect.py (line 113). After the (force, area, distance).count(0) != 1 guard at the top, the if force==0 / elif area==0 / elif distance==0 chain is exhaustive for exactly-one-zero inputs, so this line is effectively unreachable: it exists so the function never implicitly returns None if the invariant is ever broken by future edits.","triggerScenarios":"Not reachable through the public API as written. Would only fire if the top guard or the branch chain were modified (e.g. a refactor changes the count check but not the branches), or if a value compares != 0 but also != 0 in float terms (not possible for reals).","commonSituations":"You will essentially never see this at runtime; if you do, you are likely running a patched/forked version of casimir_effect.py where the validation chain was edited and became inconsistent.","solutions":["If you hit this, verify you are calling casimir_force with exactly one 0 — if that still fails, you are running modified library code.","Diff your local casimir_effect.py against upstream to find the edit that broke the invariant.","Restore the original file or fix the modified guard so count(0)==1 aligns with the branch chain."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    result = casimir_force(force=f, area=a, distance=d)\nexcept ValueError as e:\n    # defensive tail raise: indicates modified library code\n    raise RuntimeError(\"casimir_effect.py invariant broken; diff against upstream\") from e","preventionTips":["Pin the library version in requirements.","Diff local physics/casimir_effect.py against upstream after any patch.","Keep the count(0)==1 guard and the if/elif chain in sync when forking."],"tags":["physics","unreachable-code","defensive-programming"],"backgroundTag":null,"analyzedSha":"f5988cc09713315817df6a7e327e258013a94440","analyzedAt":"2026-08-14T17:30:07.041Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}