This is a simple path search algorithm for games like follows
You make a decision for selecting a color for the teil which connects to the left up cell. The color options are the direct neighbor colors. And then change the entire teil to the selected color and repeat. The optimal solution will be the one with least steps.
Here is one of the solution for this goal, it is similar to best first search algorithm.