Solve the following exercise by means of a reduction to
SAT:
- Given an n×m board and 2k pipe ends (k pairs, with a
different color for each pair) in certain positions of the board, determine
if the pipe ends of matching colors can be connected with pipes through the
board in a way that no pipes overlap and the whole board is covered.
For example, the following figure represents an input for this problem
with n=m=k=9 (numbers identify the pipe ends
with matching colors, empty cells are denoted with a dot):
· · · · · · 1 2 3
· 4 · · · · · · ·
5 · · 1 · · · · ·
· · · 2 · · · · ·
· 3 · · · · · 6 ·
· · · · 7 · · · ·
· · · · · · 8 · 8
· · · 5 · · 7 6 9
4 · · · · 9 · · ·
and this represents be a possible solution for it:
·───·───· ·───·───·───1 2 3
│ │ │ │ │
· 4 · · ·───·───·───· ·
│ │ │ │ │ │
5 · · 1 · ·───·───·───·
│ │ │ │
·───· · 2───· · ·───·───·
│ │ │ │ │
· 3 · ·───·───· · 6 ·
│ │ │ │ │ │ │
· · · · 7───· · · ·
│ │ │ │ │ │ │ │
· · · ·───· · 8 · 8
│ │ │ │ │ │
· · ·───5 · ·───7 6 9
│ │ │ │
4 ·───·───·───· 9───·───·───·
The input of the exercise and the output with the solution (when the input is
solvable) are as follows: