A solution to the n-queens problem