Working BFS puzzle solver.