C++ horse chess board program (greedy algorithm)