solving the "chess" problem