Processes a single move, updating the matrix and calculating the score. >>> play([['R', 'G'], ['R', 'G']], 0, 0, 2) ([['G', '-'], ['G', '-']], 3)
(
matrix_g: list[list[str]], pos_x: int, pos_y: int, size: int
)
| 218 | |
| 219 | |
| 220 | def play( |
| 221 | matrix_g: list[list[str]], pos_x: int, pos_y: int, size: int |
| 222 | ) -> tuple[list[list[str]], int]: |
| 223 | """ |
| 224 | Processes a single move, updating the matrix and calculating the score. |
| 225 | |
| 226 | >>> play([['R', 'G'], ['R', 'G']], 0, 0, 2) |
| 227 | ([['G', '-'], ['G', '-']], 3) |
| 228 | """ |
| 229 | |
| 230 | same_colors = find_repeat(matrix_g, pos_x, pos_y, size) |
| 231 | |
| 232 | if len(same_colors) != 0: |
| 233 | for pos in same_colors: |
| 234 | matrix_g[pos[0]][pos[1]] = "-" |
| 235 | for column in range(size): |
| 236 | matrix_g = move_x(matrix_g, column, size) |
| 237 | |
| 238 | matrix_g = move_y(matrix_g, size) |
| 239 | |
| 240 | return (matrix_g, increment_score(len(same_colors))) |
| 241 | |
| 242 | |
| 243 | def process_game(size: int, matrix: list[str], moves: list[tuple[int, int]]) -> int: |
no test coverage detected