Solution to the N Puzzle in C++