Skip to content

Instantly share code, notes, and snippets.

@josiahcoad
Last active October 28, 2022 17:05
Show Gist options
  • Save josiahcoad/13ced31ee0ee636e6d60b6b126345896 to your computer and use it in GitHub Desktop.
Save josiahcoad/13ced31ee0ee636e6d60b6b126345896 to your computer and use it in GitHub Desktop.
move_empty_tile
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