Applying the A* algorithm to a block reversal problem