Skip to content

mzdemezer/Sudoku-Solver-in-Prolog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Write solve_sudoku(Sudoku, SolvedSudoku), print_sudoku(SolvedSudoku).
For example:

?- solve_sudoku(
[	[0, 0, 0, 9, 0, 2, 1, 0, 6]
,	[0, 2, 0, 0, 6, 0, 0, 7, 9]
,	[0, 0, 9, 0, 0, 0, 0, 0, 0]
,	[3, 1, 0, 0, 0, 7, 2, 0, 0]
,	[0, 0, 0, 0, 9, 0, 0, 0, 0]
,	[0, 0, 6, 5, 0, 0, 0, 3, 8]
,	[0, 0, 0, 0, 0, 0, 5, 0, 0]
,	[0, 3, 0, 0, 4, 0, 0, 8, 0]
,	[6, 0, 1, 2, 0, 3, 0, 0, 0]
],
Sud), print_sudoku(Sud).


This should come out:
[	[8, 4, 7, 9, 3, 2, 1, 5, 6]
,	[1, 2, 3, 4, 6, 5, 8, 7, 9]
,	[5, 6, 9, 7, 1, 8, 3, 2, 4]
,	[3, 1, 4, 6, 8, 7, 2, 9, 5]
,	[2, 5, 8, 3, 9, 4, 7, 6, 1]
,	[9, 7, 6, 5, 2, 1, 4, 3, 8]
,	[4, 9, 2, 8, 7, 6, 5, 1, 3]
,	[7, 3, 5, 1, 4, 9, 6, 8, 2]
,	[6, 8, 1, 2, 5, 3, 9, 4, 7]
]

If there is more than one possible solution, then after
hitting  ;  the solver will find them too.

About

The name is self-explanatory.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages