Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to write a prolog program based on the N queens problem that decides if t

ID: 3620411 • Letter: I

Question

I need to write a prolog program based on the N queens problem that decides if the entered value for the queens on the board is safe or not. I know my safe predicates work the thing is everything before the safe was given to us to start and I don't understand it, so I need the safe predicate I wrote to be integrated with what was given to start with. Everything I wrote is below the = sign line and everything started with is above it. I also need a predicate that will print the board with the Queens on it like so:
-------------------------------------|
| | | Q | |
|------------------------------------|
| Q | | | |
|------------------------------------|
| | | | Q |
|------------------------------------|
| | Q | | |
|------------------------------------|

queens(N,Queen_places) :- range(1,N,N_list),
my_permutation(N_list,Queen_places),
safe(Queen_places),
print_board(Queen_places,N).

my_permutation(Xs,[Z|Zs]) :- select(Z,Xs,Ys), my_permutation(Ys,Zs).
my_permutation([],[]).

select(X,[X|Xs],Xs).
select(X,[Y|Ys],[Y|Zs]) :- select(X,Ys,Zs).

range(M,N,[M|Ns]) :- M < N, M1 is M + 1, range(M1,N,Ns).
range(N,N,[N]).


========================================================
queen_doesnt_hit(_,_,[]) :- !.
queen_doesnt_hit(Col,Row_dist,[A_queen_col|Other_queens]) :- !,
Diag_hit_col1 is Col + Row_dist, A_queen_col == Diag_hit_col1,
Diag_hit_col2 is Col - Row_dist, A_queen_col == Diag_hit_col2,
Row_dist1 is Row_dist + 1,
queen_doesnt_hit(Col,Row_dist1,Other_queens).

safe([_]) :- !.
safe([A_queen|Other_queens]) :- !,
queen_doesnt_hit(A_queen,1,Other_queens),
safe(Other_queens).

Explanation / Answer

Well I figured out that my problem wasnt with intigrating the 2, the problem was I was running it wrong, it all works fine now, I just need a predicate that will print the board now