Zen Puzzle Garden is NP-complete
📝 Original Info
- Title: Zen Puzzle Garden is NP-complete
- ArXiv ID: 1106.2104
- Date: 2011-06-13
- Authors: Robin Houston, Joseph White and Martyn Amos
📝 Abstract
Zen Puzzle Garden (ZPG) is a one-player puzzle game. In this paper, we prove that deciding the solvability of ZPG is NP-complete.💡 Deep Analysis
📄 Full Content
Although the problem has been studied experimentally [1], until now no formal proof of its complexity has existed. We now demonstrate that deciding the solvability of ZPG is NP-complete.
Theorem 1: Deciding the solvability of a Zen Puzzle Garden instance is NPcomplete.
Following [2], we construct a reduction from the following NP-complete problem [4]; given a cubic planar graph, does it contain a Hamiltonian circuit? That is, we construct ZPG gardens which correspond to arbitrary cubic planar graphs, and any garden we construct will have a solution iff the corresponding graph has a Hamiltonian circuit.
Preprint submitted to Elsevier September 3, 2018
To build a ZPG garden that corresponds to a cubic planar graph, G, we first draw the graph on a grid. This may always be done in such a way that the area of the grid is quadratic in the size of the graph [3]. We then convert the grid into a ZPG garden as follows. Each square of the grid is converted into a 7×7 tile, made up of either rock, sand or walkable squares. Each tile is either a straight edge, a corner, or a node of the graph with three incident edges. The first two tiles are depicted in Figure 2, and these may be rotated as required.
The node tile is constructed in such a way that, whichever sand square is covered first, it is always possible to cover the remaining sand squares and come out either of the other sides (Figure 3).
In Figure 4 we show a cubic planar graph, along with its ZPG representation. The start node is coloured in red, and the Hamiltonian cycle is shown in bold.
In the ZPG representation, the start node is encoded as a two-tile complex, occupying positions (3,6) and (3,5). The top tile is made entirely of walkable squares, where the monk is initially placed, and the lower tile is a single “gateway” tile, depicted in Figure 4 (bottom). This tile is a modified node tile with two of the upper-most rocks converted to sand. The first sand square covered must be one of these two, and the last sand square visited must be the other. This facilitates exit from and return to the start node. Any solution must pass through all other nodes only once, so any solution to the garden gives a Hamiltonian circuit though the graph.
We know from [3] that a planar graph on n nodes can be realised using a grid of area O(n 2 ), and that this grid realisation can be computed in time O(n log n), so the mapping from planar graph to ZPG garden is polynomial. Given a solution, it can easily be checked in polynomial time, since a solution is never bigger than the garden it solves. This completes the proof that ZPG is NP-complete.