C++ Sliding puzzle solver