Help with graph search problem
"Graph search" is a very general term that includes breadth-first-search and depth-first-search. Let's say you wanna do BFS on this problem.

For this problem, think of a matrix, or a state, as a node in the graph. The pseudocode might look like this:


Push the "input node" into a queue.
While desired output node is not found:


Pop an element from the queue
Go through all the "moves" that could be done on that node. For a 3x4 matrix there would be 12 possible moves.
Push the results of each move into the queue.



Hope this helps!