2
votes

I have an assignment about CLP with CT. I had a look at many block sudoku examples. I learnt how to define the list of rows, columns and boxes. However as I understood my problem is different from classical block sudoku examples.

We have a graph G=(V,E) No neighboring vertices have the same number.

gsudoku (Edges,N), label (V).

Output:

?- gsudoku([e(X,Y),e(Y,Z),e(Z,X)],2),label([X,Y,Z]).
false
?- gsudoku([e(X,Y),e(Y,Z),e(Z,X)],3),label([X,Y,Z]).
X=1 Y=2 Z=3 and (other permutations)

Should i think this as 3x3 sudoku examples because i have 3 points?

Could someone please help me how I can solve it? Advance thanks!

1
Isn't your problem just graph coloring en.wikipedia.org/wiki/Graph_coloring?Sergii Dymchenko
@SergeyDymchenko exactly you are right.Thanks for help!limonik
Here you can find a working example of a sudoku puzzle solver with a nice user interface for playing with the code and visualization for the solutions.user1812457

1 Answers

1
votes

For the future readers here is the code:

:- use_module(library(clpfd)).
gsudoku([],_).
gsudoku([e(F,T)|XS],N):- F in 1.. N,
 T in 1.. N ,
 F #\= T ,
 gsudoku(XS,N).