Question: the 'movesToSolve' function should be completed IN PYTHON # # # Complete the 'movesToSolve' function below. # # The function is expected to return an
# # # Complete the 'movesToSolve' function below. # # The function is expected to return an INTEGER. # The function accepts 2D_INTEGER_ARRAY puzzle as parameter # def movesToSolve (puzzle): A Sliding Block Puzzle is a type of puzzle in which a an N by M rectangular grid contains a single blank space and (N*M)-1 numbered tiles. The goal of the puzzle is to arrange the puzzle such that the numbers are ordered left-to-right, top-to-bottom, with the empty space in the top left. This is achieved by repeatedly sliding adjacent tiles into the empty space and thus rearranging the puzzle. You will implement a function that will take a puzzle (represented as a 2d array of integers, with 0 representing the blank space) and return the minimum number of moves to bring it to a solution. If the puzzle has no solution, you should return -1. An example move: A solved puzzle: 163 872 4.05 1 6 3 -> 8.02 4.75 012 3 4 5 6 7 8 You may make the following assumptions: All input will be well-formed Puzzles will be rectangular and will contain each number from 0 to (MN) exactly once No inputs will be null empty or zero-length N and M will be at least two and no more than 5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
