Solve the following exercise by means of a reduction to
SAT:
- Given an n×m board such that
some of the cells contain a number in {0,…,3}, find a way to draw
a set of cycles such that, given a cell with a number k, exactly k of
its four sides are part of a cycle. Cycles can’t share sides nor vertices.
The sides of a cell can belong to different cycles.
For example, the following figure represents an input for this problem
with n=m=7 (empty cells are denoted with a dot):
· · · · 2 · ·
· · · · · · 3
· 2 1 · · · ·
· · · · · 1 0
0 · · · · · ·
· · · · · 3 ·
· · · · 3 · ·
and this represents a possible solution for it with two cycles:
┌───┐
· · · · 2 │ · │ ·
┌───┘ └───┐
· · · · │ · · 3 │
┌───────────┘ ┌───┘
· │ 2 1 · · · │ ·
│ ┌───────┘
· │ · · · │ · 1 0
└───────────┘
0 · · · · · ·
┌───┐
· · · · · │ 3 │ ·
┌───┘ └───┐
· · · · │ 3 · · │
└───────────┘
The input of the exercise and the output with the solution (when the input is
solvable) are as follows: