{"record":{"id":"4e83d58a705cec0e","repo":"TheAlgorithms/Python","slug":"the-matrix-dont-match-with-size","errorCode":null,"errorMessage":"The matrix dont match with size.","messagePattern":"The matrix dont match with size\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"matrix/matrix_based_game.py","lineNumber":83,"sourceCode":"    \"\"\"\n    Validates that the number of elements in the matrix matches the given size.\n\n    >>> validate_matrix_content(['aaaa', 'aaaa', 'aaaa', 'aaaa'], 3)\n    Traceback (most recent call last):\n        ...\n    ValueError: The matrix dont match with size.\n    >>> validate_matrix_content(['aa%', 'aaa', 'aaa'], 3)\n    Traceback (most recent call last):\n        ...\n    ValueError: Matrix rows can only contain letters and numbers.\n    >>> validate_matrix_content(['aaa', 'aaa', 'aaaa'], 3)\n    Traceback (most recent call last):\n        ...\n    ValueError: Each row in the matrix must have exactly 3 characters.\n    \"\"\"\n    print(matrix)\n    if len(matrix) != size:\n        raise ValueError(\"The matrix dont match with size.\")\n    for row in matrix:\n        if len(row) != size:\n            msg = f\"Each row in the matrix must have exactly {size} characters.\"\n            raise ValueError(msg)\n        if not all(char.isalnum() for char in row):\n            raise ValueError(\"Matrix rows can only contain letters and numbers.\")\n\n\ndef validate_moves(moves: list[tuple[int, int]], size: int) -> None:\n    \"\"\"\n    >>> validate_moves([(1, 2), (-1, 0)], 3)\n    Traceback (most recent call last):\n        ...\n    ValueError: Move is out of bounds for a matrix.\n    \"\"\"\n    for move in moves:\n        x, y = move\n        if not (0 <= x < size and 0 <= y < size):","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/matrix/matrix_based_game.py#L65-L101","documentation":"Error \"The matrix dont match with size.\" thrown in TheAlgorithms/Python.","triggerScenarios":"Thrown at matrix/matrix_based_game.py:83 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide a matrix with exactly 'size' rows."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f5988cc09713315817df6a7e327e258013a94440","analyzedAt":"2026-08-14T17:30:07.041Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}