Java/nQueens.java
public static boolean solveBoard(char[][] board, int queenCount) {
        //basically we are running through the board, and checking if a spot is open
        for (int row = 0; row < Sizes.grid_Size; row++) {
            for (int column = 0; column < Sizes.grid_Size; column++) {
                //so, if a spot is open
                if (board[row][column] == '-') {
                    //we check if this is spot is a valid placement
                    if (isValidPlacement(board, row, column)) {
                        //and if it is a valid placement, we put a queen there.
                        board[row][column] = 'Q';
                        //ok, but what if we can't solve the board with a queen in this position?
                        /*
                         * here is when recursion comes in handy, basically, we are checking if we
                         * can solve the board in the given position, if we can't, we set the place as
                         * '-' open, and iterate through the matrix(board) once again, but in the next
                         * spot
                         */
                        if (solveBoard(board, queenCount + 1)) {
                            return true;
                        } else {
                            board[row][column] = '-';
                        }
                    }
                }
            }
        }
        /*so this right here, guarantees that we loop until we get N queens on the NxN board,
         *otherwise, the code would stop before reaching the N queens, since we can easily have
         *a solution using fewer queens on a bigger board.
         */
        return queenCount == Sizes.grid_Size;
    }
/*
     * and here comes the backtracking idea, and to be honest, that wasn't really hard, since I already had
     * the experience from sudoku, understanding the recursion there wasn't as hard as it was on the first time.
     * */
and here comes the backtracking idea, and to be honest, that wasn't really hard, since I already had
the experience from sudoku, understanding the recursion there wasn't as hard as it was on the first time.
and here comes the backtracking idea and to be honest that wasn ' t really hard since I already had the experience from sudoku understanding the recursion there wasn ' t as hard as it was on the first time .
public static boolean solveBoard(char[][] board, int queenCount) {
        for (int row = 0; row < Sizes.grid_Size; row++) {
            for (int column = 0; column < Sizes.grid_Size; column++) {
                if (board[row][column] == '-') {
                    if (isValidPlacement(board, row, column)) {
                        board[row][column] = 'Q';
                        /*
                         * here is when recursion comes in handy, basically, we are checking if we
                         * can solve the board in the given position, if we can't, we set the place as
                         * '-' open, and iterate through the matrix(board) once again, but in the next
                         * spot
                         */
                        if (solveBoard(board, queenCount + 1)) {
                            return true;
                        } else {
                            board[row][column] = '-';
                        }
                    }
                }
            }
        }
        /*so this right here, guarantees that we loop until we get N queens on the NxN board,
         *otherwise, the code would stop before reaching the N queens, since we can easily have
         *a solution using fewer queens on a bigger board.
         */
        return queenCount == Sizes.grid_Size;
    }
public static boolean solveBoard ( char [ ] [ ] board , int queenCount ) { for ( int row = 0 ; row < Sizes . grid_Size ; row ++ ) { for ( int column = 0 ; column < Sizes . grid_Size ; column ++ ) { if ( board [ row ] [ column ] == '-' ) { if ( isValidPlacement ( board , row , column ) ) { board [ row ] [ column ] = 'Q' ; /*
                         * here is when recursion comes in handy, basically, we are checking if we
                         * can solve the board in the given position, if we can't, we set the place as
                         * '-' open, and iterate through the matrix(board) once again, but in the next
                         * spot
                         */ if ( solveBoard ( board , queenCount + 1 ) ) { return true ; } else { board [ row ] [ column ] = '-' ; } } } } } /*so this right here, guarantees that we loop until we get N queens on the NxN board,
         *otherwise, the code would stop before reaching the N queens, since we can easily have
         *a solution using fewer queens on a bigger board.
         */ return queenCount == Sizes . grid_Size ; }
and here comes the backtracking idea, and to be honest, that wasn't really hard, since I already had
 the experience from sudoku, understanding the recursion there wasn't as hard as it was on the first time.
and here comes the backtracking idea and to be honest that wasn ' t really hard since I already had the experience from sudoku understanding the recursion there wasn ' t as hard as it was on the first time .
//basically we are running through the board, and checking if a spot is open //so, if a spot is open //we check if this is spot is a valid placement //and if it is a valid placement, we put a queen there. //ok, but what if we can't solve the board with a queen in this position?