Solver for ant on chessboard problem