An NP-Complete Problem in Grid Coloring
A c-coloring of G(n,m)=n x m is a mapping of G(n,m) into {1,…,c} such that no four corners forming a rectangle have the same color. In 2009 a challenge was proposed via the internet to find a 4-coloring of G(17,17). This attracted considerable attention from the popular mathematics community. A coloring was produced; however, finding it proved to be difficult. The question arises: is the problem of grid coloring is difficult in general? We show that the problem of, given a partial coloring of a grid, can it be extended to a full (proper) coloring, is NP-complete.
💡 Research Summary
The paper introduces a combinatorial problem that at first glance appears to be a simple puzzle but in fact belongs to the class of computationally intractable problems. The setting is an n × m rectangular grid G(n,m) whose cells must be assigned colors from a set {1,…,c}. The only restriction, called the “rectangle‑free” condition, is that no four cells that form the corners of an axis‑aligned rectangle may all receive the same color. This rule is reminiscent of Latin rectangles but differs because it allows repeated colors as long as the forbidden pattern does not appear.
The central decision problem studied is EXTEND‑GRID‑COLORING: given a partial coloring P of some cells of G(n,m) together with the parameters n, m, and c, does there exist a complete coloring F that extends P and satisfies the rectangle‑free condition? The authors first observe that the problem lies in NP. A nondeterministic algorithm can guess the colors of the unfilled cells and then verify in O(n²m²) time that every possible rectangle respects the rule, which is polynomial in the input size.
To establish NP‑hardness, the authors construct a polynomial‑time many‑one reduction from 3‑SAT, the canonical NP‑complete problem. For each Boolean variable they allocate a dedicated “variable gadget” consisting of a narrow strip of the grid. The gadget is pre‑colored so that only two colors are permissible for the undecided cells; these two colors encode the truth assignment of the variable (e.g., color 1 = true, color 2 = false). For each clause (ℓ₁ ∨ ℓ₂ ∨ ℓ₃) they create a “clause gadget” that intersects the three corresponding variable strips. The rectangle‑free condition is exploited to enforce that if all three literals are assigned false, then the clause gadget inevitably contains a monochromatic rectangle, violating the rule. Consequently, a valid extension of the partial coloring exists if and only if the original 3‑SAT instance is satisfiable. The construction uses O(n + m) grid size and a constant number of colors (c ≥ 3), thereby showing that EXTEND‑GRID‑COLORING is NP‑hard for any c ≥ 3.
The paper also discusses special cases. When c = 2 the rectangle‑free condition becomes trivial, because any two‑coloring of a grid can avoid a monochromatic rectangle by simple parity arguments; thus the problem is solvable in polynomial time. For c ≥ 3 the NP‑completeness persists. The authors point out that the celebrated 2009 Internet challenge to find a 4‑coloring of a 17 × 17 grid is an instance of the problem with c = 4 and a non‑trivial partial coloring; the difficulty experienced by participants is explained by the underlying NP‑completeness.
Beyond the theoretical classification, the authors highlight several application domains where rectangle‑free colorings are relevant: experimental design (avoiding confounding patterns), error‑correcting codes (preventing certain error patterns), and computer vision (suppressing repetitive texture artifacts). In each case, the NP‑completeness result suggests that exact solutions are unlikely to be feasible for large instances, motivating the development of heuristics, approximation algorithms, or fixed‑parameter tractable (FPT) approaches.
Finally, the paper outlines directions for future work. One line of inquiry is the parameterized complexity of the problem when one dimension (rows or columns) is bounded, which may admit FPT algorithms. Another is the design of polynomial‑time approximation schemes that guarantee a coloring with “few” monochromatic rectangles, useful in practical settings where a small number of violations is acceptable. The authors also propose studying average‑case complexity on random partial colorings and extending the model to forbid other geometric patterns such as axis‑aligned triangles.
In summary, the authors rigorously prove that extending a partial rectangle‑free coloring of a grid to a full coloring is NP‑complete for three or more colors. This result bridges a popular recreational puzzle with deep complexity theory, clarifies why certain grid‑coloring challenges are computationally hard, and opens a rich avenue for algorithmic research in both theory and applications.