Solves an N-Queens problem