Last active
October 28, 2022 17:05
-
-
Save josiahcoad/13ced31ee0ee636e6d60b6b126345896 to your computer and use it in GitHub Desktop.
move_empty_tile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Dict, List, Tuple | |
from copy import deepcopy | |
Matrix = List[List[int]] | |
def move_empty_tile(matrix: Matrix, empty_tile: Tuple[int, int], new_empty_tile: Tuple[int, int]) -> Matrix: | |
row, col = empty_tile | |
new_row, new_col = new_empty_tile | |
new_matrix = deepcopy(matrix) | |
temp = new_matrix[new_row][new_col] | |
new_matrix[row][col] = temp | |
new_matrix[new_row][new_col] = 0 | |
return new_matrix |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment