{"record":{"id":"2d9489f2ff228584","repo":"TheAlgorithms/Python","slug":"the-board-should-be-a-non-empty-matrix-of-single-c","errorCode":null,"errorMessage":"The board should be a non empty matrix of single chars strings.","messagePattern":"The board should be a non empty matrix of single chars strings\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"backtracking/word_search.py","lineNumber":132,"sourceCode":"    ValueError: The board should be a non empty matrix of single chars strings.\n    >>> word_exists([], \"AB\")\n    Traceback (most recent call last):\n        ...\n    ValueError: The board should be a non empty matrix of single chars strings.\n    >>> word_exists([[\"A\"], [21]], \"AB\")\n    Traceback (most recent call last):\n        ...\n    ValueError: The board should be a non empty matrix of single chars strings.\n    \"\"\"\n\n    # Validate board\n    board_error_message = (\n        \"The board should be a non empty matrix of single chars strings.\"\n    )\n\n    len_board = len(board)\n    if not isinstance(board, list) or len(board) == 0:\n        raise ValueError(board_error_message)\n\n    for row in board:\n        if not isinstance(row, list) or len(row) == 0:\n            raise ValueError(board_error_message)\n\n        for item in row:\n            if not isinstance(item, str) or len(item) != 1:\n                raise ValueError(board_error_message)\n\n    # Validate word\n    if not isinstance(word, str) or len(word) == 0:\n        raise ValueError(\n            \"The word parameter should be a string of length greater than 0.\"\n        )\n\n    len_board_column = len(board[0])\n    for i in range(len_board):\n        for j in range(len_board_column):","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/backtracking/word_search.py#L114-L150","documentation":"Raised by centripetal() in physics/centripetal_force.py when radius <= 0. Radius is the divisor in (mass * v**2)/radius, so zero would divide by zero and negative radius is unphysical for circular motion. Unlike the mass check, this one rejects zero too.","triggerScenarios":"centripetal(10, 15, 0) or centripetal(10, 15, -5); passing a radius of 0 because of an uninitialized variable; computing radius as a difference that collapsed to 0.","commonSituations":"Default-initialized radius = 0.0 never overwritten; geometry code producing a degenerate circle (radius 0) for coincident points; unit tests passing 0 as a placeholder.","solutions":["Ensure radius is a positive number before calling; use a realistic default (e.g. 1.0) instead of 0.","If radius is computed geometrically, guard the degenerate case (identical points) upstream.","Catch ValueError and reject the input record."],"exampleFix":"# before\nforce = centripetal(m, v, r)  # r may be 0 for coincident points\n\n# after\nif r <= 0:\n    raise ValueError(\"degenerate circle: radius must be > 0\")\nforce = centripetal(m, v, r)","handlingStrategy":"validation","validationCode":"if radius <= 0:\n    raise ValueError(f\"radius must be > 0, got {radius}\")\nf = centripetal(mass, velocity, radius)","typeGuard":"def is_positive_radius(r: object) -> bool:\n    return isinstance(r, (int, float)) and not isinstance(r, bool) and r > 0","tryCatchPattern":"try:\n    f = centripetal(m, v, r)\nexcept ValueError as e:\n    if \"radius\" in str(e):\n        r = r or 1.0  # replace uninitialized default\n        f = centripetal(m, v, r)\n    else:\n        raise","preventionTips":["Never default radius to 0; use 1.0 or require the value.","Zero is rejected as well as negative.","Guard degenerate geometry (coincident centers) before computing r."],"tags":["physics","input-validation","division-by-zero"],"backgroundTag":null,"analyzedSha":"f5988cc09713315817df6a7e327e258013a94440","analyzedAt":"2026-08-14T17:30:07.041Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}