Kakuro-prolog constraint programming


I have an assignment regarding Prolog constraint programming.

Kakuro:

In Kakuro, the problem is to fill in the white squares with digits 1 through 9 so that they sum to the numbers shown in the dark squares. A dark square is shown with one or two sums, separated by a diagonal line. A sum above the diagonal denotes the total of the row of white squares to its right; A sum below the diagonal is the total of the column of white squares beneath it. Moreover, in any contiguous run of the white squares all the digits must be different, that is, a digit can occur only once within a sum. Zero is also precluded from the sum. The challenge is to use finite domain constraint logic programming to solve the Kakuro puzzle given below, to the left. The solution should print its solution in the format given below, to the right. Note that the example just illustrates layout; it cannot be a solution since the third column contains a line that contains three ones.

1695_Kakuro.jpg

Suggestions:

Your solution must be a SWI-Prolog program, that uses the clpfd library. Your solution should use the across(Row, Column, Length, Sum) and down(Row, Column, Length, Sum) predicates that are given in the file spec.pl that is available from the Moodle course page. These predicates, together, specify the positions of the white squares, their number and their sum. In addition, the predicate black(Row, Column) details all the black squares; your solution might make use of this predicate too. These predicates have been supplied to simplify the assessment and you are strongly advised to use them. You might want to call these predicates from findall. There is no reason why you cannot use predicates supplied in the SWI-Prolog libraries, such as transpose which computes the transpose of a matrix represented as a list of rows. For instance the query ?- transpose([[1,2], [3,4]], T) will instantiate T to [[1, 3], [2, 4]]. Look up sum in the clpfd documentation. Just fifteen marks will be awarded for this assessment; you should aim to make your code short and clear.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Kakuro-prolog constraint programming
Reference No:- TGS01238138

Expected delivery within 24 Hours