This is a famous sliding puzzle based on A* algorithm. This is a part of Algorithms course by Sedgewick on coursera. This code passes 100/100 tests on submission.
The problem. The 8-puzzle is a sliding puzzle that is played on a 3-by-3 grid with 8 square tiles labeled 1 through 8, plus a blank square. The goal is to rearrange the tiles so that they are in row-major order, using as few moves as possible. You are permitted to slide tiles either horizontally or vertically into the blank square. The following diagram shows a sequence of moves from an initial board (left) to the goal board (right).
For complete documentation click here.