% this program places N queenson the NxN board % a/ randomly % b/ one queen in each column % c/ onequeen in each column and one queen in each row % and checks the number of attacks. % It places the queens repeatedly until there is no attack. % This is a brute force method for solving the N-queen problem. clear clc N = 4; numAttacks = 1; attempt_counter = 0; while numAttacks ~= 0 % A = place_N_queens_random(N); % A = place_N_queens_cols(N); A = place_N_queens_cols_rows(N); numAttacks = find_attacks_gen(A, N); attempt_counter = attempt_counter + 1; end attempt_counter A