Simulates gravity in a specific column. >>> move_x([['-', 'A'], ['-', '-'], ['-', 'C']], 1, 2) [['-', '-'], ['-', 'A'], ['-', 'C']]
(matrix_g: list[list[str]], column: int, size: int)
| 174 | |
| 175 | |
| 176 | def move_x(matrix_g: list[list[str]], column: int, size: int) -> list[list[str]]: |
| 177 | """ |
| 178 | Simulates gravity in a specific column. |
| 179 | |
| 180 | >>> move_x([['-', 'A'], ['-', '-'], ['-', 'C']], 1, 2) |
| 181 | [['-', '-'], ['-', 'A'], ['-', 'C']] |
| 182 | """ |
| 183 | |
| 184 | new_list = [] |
| 185 | |
| 186 | for row in range(size): |
| 187 | if matrix_g[row][column] != "-": |
| 188 | new_list.append(matrix_g[row][column]) |
| 189 | else: |
| 190 | new_list.insert(0, matrix_g[row][column]) |
| 191 | for row in range(size): |
| 192 | matrix_g[row][column] = new_list[row] |
| 193 | return matrix_g |
| 194 | |
| 195 | |
| 196 | def move_y(matrix_g: list[list[str]], size: int) -> list[list[str]]: |