[Paper Review] Sorting Balls and Water: Equivalence and Computational Complexity
This paper establishes the computational equivalence between the ball sort puzzle and water sort puzzle, proving both are NP-complete. It shows that any solvable instance admits a polynomial-length solution sequence, and provides tight bounds on the minimum number of empty bins required to guarantee solvability across all configurations, resolving a key structural constraint in these popular sorting puzzles.
Various forms of sorting problems have been studied over the years. Recently, two kinds of sorting puzzle apps are popularized. In these puzzles, we are given a set of bins filled with colored units, balls or water, and some empty bins. These puzzles allow us to move colored units from a bin to another when the colors involved match in some way or the target bin is empty. The goal of these puzzles is to sort all the color units in order. We investigate computational complexities of these puzzles. We first show that these two puzzles are essentially the same from the viewpoint of solvability. That is, an instance is sortable by ball-moves if and only if it is sortable by water-moves. We also show that every yes-instance has a solution of polynomial length, which implies that these puzzles belong to in NP. We then show that these puzzles are NP-complete. For some special cases, we give polynomial-time algorithms. We finally consider the number of empty bins sufficient for making all instances solvable and give non-trivial upper and lower bounds in terms of the number of filled bins and the capacity of bins.
Motivation & Objective
- To investigate the computational complexity of the ball sort puzzle (BSP) and water sort puzzle (WSP), two popular recreational sorting puzzles.
- To determine whether the solvability of BSP and WSP are equivalent under their respective move rules.
- To establish the NP-completeness of both puzzles and analyze the complexity of finding shortest solution sequences.
- To derive tight bounds on the number of empty bins required to make all instances solvable, in terms of bin capacity h and number of filled bins n.
- To provide polynomial-time algorithms for special cases, such as when h = 2 and the number of colors equals n.
Proposed method
- Prove equivalence between BSP and WSP by showing that any instance solvable via water moves is also solvable via ball moves, and vice versa, using structural analysis of move sequences.
- Establish that every yes-instance of either puzzle admits a solution sequence of length polynomial in n + h, placing both problems in NP.
- Use a reduction from 3-Partition to prove NP-completeness of BSP and WSP, with a modified version showing NP-completeness even for finding shortest paths in trivial yes-instances.
- Analyze the minimal number of empty bins required for solvability by constructing extremal configurations and applying recursive inequalities on the number of removed units per color.
- Derive lower and upper bounds on the number of empty bins k(n,h) using extremal combinatorial arguments and recursive bounds on unit removal sequences.
- Provide a polynomial-time algorithm for the case h = 2 and n colors, leveraging the fact that each bin can hold at most two units and using a greedy bucket sort-like strategy.
Experimental results
Research questions
- RQ1Are the ball sort puzzle and water sort puzzle computationally equivalent in terms of solvability?
- RQ2Is the problem of determining whether a given initial configuration can be sorted into monochromatic bins NP-complete for both puzzles?
- RQ3Can a shortest solution sequence be found in polynomial time for trivial yes-instances of the water sort puzzle?
- RQ4What is the minimum number of empty bins required to guarantee that every instance with n filled bins of capacity h is solvable?
- RQ5Does the required number of empty bins depend on both h and n, or is it independent of n for fixed h?
Key findings
- The ball sort puzzle (BSP) and water sort puzzle (WSP) are computationally equivalent: an instance is solvable via ball moves if and only if it is solvable via water moves.
- Both BSP and WSP are NP-complete, even when restricted to instances with a single color per bin and a small number of empty bins.
- Every yes-instance of either puzzle admits a solution sequence of length polynomial in n + h, which certifies membership in NP.
- For the special case where bin capacity h = 2 and the number of colors equals n, both puzzles can be solved in polynomial time O(hn).
- The minimum number of empty bins required to make all instances solvable is bounded below by ⌈19/64 min{n, h}⌉ and above by ⌈(h−1)/h n⌉.
- The lower bound of ⌈19/64 min{n, h}⌉ is tight and derived from a recursive inequality on the number of units of each color removed from their initial positions, assuming worst-case configurations.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.