Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Amin Raslan
CLPFD MiniZinc
Commits
7383903e
Commit
7383903e
authored
Sep 09, 2021
by
Amin Raslan
Browse files
Update officer_problem.pl
parent
cf9ec630
Changes
1
Hide whitespace changes
Inline
Side-by-side
officer_problem.pl
View file @
7383903e
...
@@ -7,15 +7,15 @@ officer_problem(N, Square) :-
...
@@ -7,15 +7,15 @@ officer_problem(N, Square) :-
maplist
(
set_inner_length
(
2
),
Square
),
maplist
(
set_inner_length
(
2
),
Square
),
append
(
Square
,
Vs
),
append
(
Square
,
Vs
),
maplist
(
set_domain
(
N
),
Vs
),
maplist
(
set_domain
(
N
),
Vs
),
square2lists
(
Square
,
L1
,
L2
),
square2lists
(
Square
,
Xs
,
Ys
),
maplist
(
all_different
,
L1
),
maplist
(
all_different
,
Xs
),
maplist
(
all_different
,
L2
),
maplist
(
all_different
,
Ys
),
transpose
(
Square
,
TransposedSquare
),
transpose
(
Square
,
TransposedSquare
),
square2lists
(
TransposedSquare
,
L3
,
L4
),
square2lists
(
TransposedSquare
,
TXs
,
TYs
),
maplist
(
all_different
,
L3
),
maplist
(
all_different
,
TXs
),
maplist
(
all_different
,
L4
),
maplist
(
all_different
,
TYs
),
maplist
(
labeling
([]),
Vs
),
maplist
(
labeling
([]),
Vs
),
unique_combination
(
Square
),
unique_combination
_xy
(
Square
),
maplist
(
portray_clause
,
Square
).
maplist
(
portray_clause
,
Square
).
set_inner_length
(
_
,[])
:-
!.
set_inner_length
(
_
,[])
:-
!.
...
@@ -34,21 +34,21 @@ square2lists([[H|TH]|TR], [[H1|T1]|TR1], [[H2|T2]|TR2]) :-
...
@@ -34,21 +34,21 @@ square2lists([[H|TH]|TR], [[H1|T1]|TR1], [[H2|T2]|TR2]) :-
H
=
[
H1
,
H2
],
H
=
[
H1
,
H2
],
square2lists
([
TH
|
TR
],
[
T1
|
TR1
],
[
T2
|
TR2
]).
square2lists
([
TH
|
TR
],
[
T1
|
TR1
],
[
T2
|
TR2
]).
unique_combination
([
_
])
:-
!.
unique_combination
_xy
([
_
])
:-
!.
unique_combination
([
H
|
T
])
:-
unique_combination
_xy
([
H
|
T
])
:-
unique_combination
(
H
,
T
),
unique_combination
_xy
(
H
,
T
),
unique_combination
(
T
).
unique_combination
_xy
(
T
).
unique_combination
([],
_
)
:-
!.
unique_combination
_xy
([],
_
)
:-
!.
unique_combination
([
H
|
T
],
Lists
)
:-
unique_combination
_xy
([
H
|
T
],
Lists
)
:-
H
=
[
H1
,
H2
],
H
=
[
H1
,
H2
],
unique_combination
(
H1
,
H2
,
Lists
),
unique_combination
_xy
(
H1
,
H2
,
Lists
),
unique_combination
(
T
,
Lists
).
unique_combination
_xy
(
T
,
Lists
).
unique_combination
(
_
,
_
,[])
:-
!.
unique_combination
_xy
(
_
,
_
,[])
:-
!.
unique_combination
(
E1
,
E2
,
[[
H
|
TH
]|
TR
])
:-
unique_combination
_xy
(
E1
,
E2
,
[[
H
|
TH
]|
TR
])
:-
H
=
[
H1
,
H2
],
H
=
[
H1
,
H2
],
(
H1
==
E1
->
(
H2
#
\
=
E2
,
unique_combination
(
E1
,
E2
,
TR
));
(
H1
==
E1
->
(
H2
#
\
=
E2
,
unique_combination
_xy
(
E1
,
E2
,
TR
));
unique_combination
(
E1
,
E2
,
[
TH
|
TR
])).
unique_combination
_xy
(
E1
,
E2
,
[
TH
|
TR
])).
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment