Question: IN PYTHON function takes in a puzzle (represented as a 2d array of integers, with 0 representing the blank space) returns the minimum number of
2. Sliding Blocks 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: 1 6 3 8 7 2 -> 4 05 163 802 012 3 4 5 4 75 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 (M*N) 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
