Question: Write a program that solves N-puzzle in n*n grid such that you rearrange the square blocks of the puzzle to be in order with the

Write a program that solves N-puzzle in n*n grid such that you rearrange the square blocks of the puzzle to be in order with the fewest possible moves. The puzzle includes 1 to N numbers with one blank space and you can move the squares horizontally and vertically into the blank space. 8-puzzle is a 3*3 grid labeled 1 though 8 and one blank square. 15-puzzle is a 4*4 grid labeled 1 through 15 and one blank square. Use A* search algorithm in your implementation. Constraints: 3 <= n <=25 Input Format: A file with n lines; each line has n numbers separated by tab. This initiates the puzzle configuration. 0 refers to the blank space. You have n-puzzle.txt as a sample file. Your code should work in any data size within the constraints

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Algorithms Questions!