Answered step by step
Verified Expert Solution
Question
1 Approved Answer
prolog CLP #1 Design and implement Prolog CLP program (sudoku 1) to generate a Sudoku sample problem and its solution. Your program should do: (1)
prolog CLP
#1 Design and implement Prolog CLP program (sudoku 1) to generate a Sudoku sample problem and its solution. Your program should do: (1) to generate the solution first, then (2) to generate the problem out of the solution, and (3) to solve the problem to generate the solution Your program should use random between/3 to generate a random number between 1-9 for the first number of each row, to make each run to be unique (to generate unique problem and solution) [Note that the solution by the program in (3) may not be same as the original Sudoku in (1).] As we discussed in the class, you may use the following code as your base to work on this problem use.module(library (clefd)) sudoku(Rows-length(Rows, 9), maplist(lengthlist(9), Rows) append(Rows, Vs) Vs ins 1.9, maplist(all distinct, Rows) transpose(Rows, Columns), maplist(all distinct, Columns) Rows [AB,C,D,E,F,G,H,I] blocks(A, B, C), blocks(D, E, F), blocks(G, H, I) length list L, Ls): length(Ls, L) blocks(], 0. 0) blocks(AB,CIBs1], [D,E,FIBs2], [G,H.IBs3]) - all.distinct(lA,B,C,D,E,F,G,H,I], blocks(Bs1, Bs2, Bs3) %% the following problem/2 with problem 1 will be added (with assert) to be added %% to run the Sudoku program with problem! shown above. The first argument is the problem ID number (from 1 to 3) 2- sudoku1 1. Sudoku solution for the problem [9,8,7,6,5,4,3,2,1] [2,4,6,1,7,3,9,8,5] [3,5,1,9,2,8,7,4,6] 1,2,8,5,3,7,6,9,4] [6,3,4,8,9,2,1,5,7 [7,9,5,4,6,1,8,3,2] [5,1,9,2,8,6,4.7,3] [4,7,2.3,1,9,5,6,8] [8,6,3,7,4,5,2,1,9] 4 2. Sudoku problem generated from the solution in 1 ** 3. Sudoku solution solved by the program using CLP, for the problem in 2 [9,8,7,6,5,4,3,2,1] [2,4,6,1,7,3,9,8,5] [3,5,1,9,2,8,7,4,6] 1,2,8,5,3,7,6,9,4] [6,3,4,8,9,2,1,5,7 [7,9,5,4,6,1,8,3,2] [5,1,9,2,8,6,4.7,3] [4,7,2.3,1,9,5,6,8] [8,6,3,7,4,5,2,1,9]Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started