Prolog Programming Write a Prolog program that finds all pos
Prolog Programming:
Write a Prolog program that finds all possible arrangements for placing these 3 symbols: in a 3 times 3 grid, so that each symbol appears only once in each row and once in each column. For example this would be a possible valid arrangement!Solution
main:- Rows=4,Columns=4, gen_matrix(Columns,Rows,Matrix), sol_puzzle(Matrix), disp_matrix(Matrix). gen_list(N, [ ]) :- N =< 0, !. gen_list(N, [_ | T]) :- N > 0, N2 is N - 1, generate_list(N2, T). gen_matrix(_, N, []) :- N =< 0, !. gen_matrix(M, N, [R|T]) :- generate_list(M,R), N2 is N - 1, gen_matrix(M, N2, T).