From a236c9e4889b31ba825a719be68c44ffb844c607 Mon Sep 17 00:00:00 2001 From: Anuj Kaushik <49589568+aiquiral@users.noreply.github.com> Date: Tue, 18 May 2021 13:19:40 +0530 Subject: [PATCH] Add files via upload --- db.pl | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 db.pl diff --git a/db.pl b/db.pl new file mode 100644 index 0000000..1b5dc36 --- /dev/null +++ b/db.pl @@ -0,0 +1,30 @@ + +:- use_module(library(clpfd)). + +sudoku(Rows) :- + length(Rows, 9), + maplist(same_length(Rows), Rows), + append(Rows, Vs), + Vs ins 1..9, + maplist(all_distinct, Rows), + transpose(Rows, Columns), + maplist(all_distinct, Columns), + Rows = [As,Bs,Cs,Ds,Es,Fs,Gs,Hs,Is], + square(As, Bs, Cs), + square(Ds, Es, Fs), + square(Gs, Hs, Is). + +square([], [], []). +square([N1,N2,N3|Ns1], [N4,N5,N6|Ns2], [N7,N8,N9|Ns3]) :- + all_distinct([N1,N2,N3,N4,N5,N6,N7,N8,N9]), + square(Ns1, Ns2, Ns3). + +problem(1, [[_,_,_,_,_,4,_,_,2], + [_,6,_,2,_,_,_,3,_], + [_,8,_,_,_,3,5,_,9], + [_,4,_,_,_,_,1,_,_], + [1,_,_,7,_,5,_,_,_], + [5,_,3,_,_,_,_,_,_], + [_,9,_,3,_,_,_,_,_], + [_,_,4,_,6,1,_,_,_], + [_,_,5,_,_,_,7,_,_]]). \ No newline at end of file