{"record":{"id":"d7cc369e1517cb76","repo":"TheAlgorithms/Python","slug":"no-solution-exists","errorCode":null,"errorMessage":"No solution exists!","messagePattern":"No solution exists!","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"backtracking/rat_in_maze.py","lineNumber":136,"sourceCode":"    Traceback (most recent call last):\n        ...\n    ValueError: Invalid source or destination coordinates\n    \"\"\"\n    size = len(maze)\n    # Check if source and destination coordinates are Invalid.\n    if not (0 <= source_row <= size - 1 and 0 <= source_column <= size - 1) or (\n        not (0 <= destination_row <= size - 1 and 0 <= destination_column <= size - 1)\n    ):\n        raise ValueError(\"Invalid source or destination coordinates\")\n    # We need to create solution object to save path.\n    solutions = [[1 for _ in range(size)] for _ in range(size)]\n    solved = run_maze(\n        maze, source_row, source_column, destination_row, destination_column, solutions\n    )\n    if solved:\n        return solutions\n    else:\n        raise ValueError(\"No solution exists!\")\n\n\ndef run_maze(\n    maze: list[list[int]],\n    i: int,\n    j: int,\n    destination_row: int,\n    destination_column: int,\n    solutions: list[list[int]],\n) -> bool:\n    \"\"\"\n    This method is recursive starting from (i, j) and going in one of four directions:\n    up, down, left, right.\n    If a path is found to destination it returns True otherwise it returns False.\n    Parameters\n        maze: A two dimensional matrix of zeros and ones.\n        i, j : coordinates of matrix\n        solutions: A two dimensional matrix of solutions.","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/backtracking/rat_in_maze.py#L118-L154","documentation":"Raised by centripetal() in physics/centripetal_force.py when mass is negative. The function returns (mass * v**2) / radius for centripetal force; negative mass is unphysical, so it is rejected. Note only mass < 0 is rejected — a mass of exactly 0 is accepted and returns 0.0, and the velocity sign is squared away (negative velocities are fine, per the doctests).","triggerScenarios":"centripetal(-10, 15, 5); passing a signed mass from a system that encodes direction/charge in the mass sign; argument-order confusion (passing a negative velocity into the mass slot).","commonSituations":"Argument order mistakes — signature is centripetal(mass, velocity, radius) and velocity may legitimately be negative (e.g. centripetal(15.5, -30, 10) is valid), so a swapped call like centripetal(-30, 15.5, 10) raises.","solutions":["Check the parameter order: centripetal(mass, velocity, radius).","Validate mass >= 0 before calling if mass comes from external data.","Catch ValueError for user-supplied inputs and surface a clear message."],"exampleFix":"# before\ncentripetal(-30, 15.5, 10)  # args swapped: velocity in mass slot\n\n# after\ncentripetal(15.5, -30, 10)  # mass=15.5, velocity=-30, radius=10 -> 1395.0","handlingStrategy":"validation","validationCode":"if mass < 0:\n    raise ValueError(f\"mass must be >= 0, got {mass}\")\nf = centripetal(mass, velocity, radius)","typeGuard":"def is_valid_mass(m: object) -> bool:\n    return isinstance(m, (int, float)) and not isinstance(m, bool) and m >= 0","tryCatchPattern":"try:\n    f = centripetal(m, v, r)\nexcept ValueError as e:\n    if \"mass\" in str(e):\n        raise ValueError(\"check argument order: centripetal(mass, velocity, radius)\") from e\n    raise","preventionTips":["Signature is centripetal(mass, velocity, radius); negative velocity is legal, negative mass is not.","Mass 0 is accepted (returns 0.0).","Use keyword-style review when copying formulas from texts."],"tags":["physics","argument-order","input-validation"],"backgroundTag":null,"analyzedSha":"f5988cc09713315817df6a7e327e258013a94440","analyzedAt":"2026-08-14T17:30:07.041Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}