Taming the Search Space: Solving and Generating Hitori and Binairo Puzzles
This paper compares backtracking with domain-specific optimizations against SAT-based solving for Hitori and Binairo puzzles, demonstrating that constraint propagation significantly enhances backtracking performance while revealing that SAT solvers excel at Binairo but struggle with Hitori due to the computational cost of iterative connectivity checks.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
The Great Logic Hunt: Taming the Puzzle Beast
Imagine you are a detective trying to solve a mystery, but instead of fingerprints, you have a grid of numbers and a set of strict rules. This is the world of Constraint Satisfaction Problems (CSPs). In the realm of computer science, a CSP is like a giant game of "fill in the blanks" where every choice you make must fit perfectly with every other choice. If you pick a number for one spot, it might instantly rule out ten other spots. The challenge isn't just finding a solution, but finding the one correct solution hidden inside a massive forest of wrong guesses.
To navigate this forest, computers use two main strategies. The first is Backtracking, which is like walking through a maze: you take a step, and if you hit a wall, you go back and try a different path. The second is SAT Solving, which is like translating the entire maze into a giant, complex sentence made of "ANDs" and "ORs" and asking a super-fast machine to tell you if that sentence can ever be true. While these puzzles are often just fun brain teasers for humans, they are actually perfect training grounds for scientists to test how well computers can think, plan, and avoid getting lost in their own logic.
Taming the Search Space: A Tale of Two Puzzles
In this paper, researchers Lukas Zandomeneghi, Rainhard Dieter Findling, and Marc Kurz decided to put two popular logic puzzles—Hitori and Binairo—under the microscope. Think of these puzzles as two different types of mazes with very different rules.
Hitori is played on a grid of numbers. Your job is to "black out" some cells so that no number appears twice in any row or column, no two black cells touch each other, and all the remaining white cells stay connected like a single island. It's a bit like a game of "don't touch" where you also have to keep your friends holding hands.
Binairo (also known as Takuzu) is a binary puzzle. You have a grid of 0s and 1s. You must fill in the empty spots so that every row and column has an equal number of 0s and 1s, you never see three of the same number in a row, and no two rows or columns look exactly the same. It's a game of balance and variety.
The authors wanted to see which computer strategy works best for each: the careful, step-by-step Backtracking detective or the lightning-fast SAT (Boolean Satisfiability) translator. To do this fairly, they first built their own puzzle generators to create thousands of unique, solvable puzzles of various sizes, ensuring they weren't just testing on easy or broken examples.
The Results: One Size Does Not Fit All
The findings were surprising and showed that the "best" tool depends entirely on the shape of the puzzle.
For Binairo: The SAT Solver Wins the Race
When it came to Binairo, the SAT-based solver was the undisputed champion. It solved every single puzzle the researchers threw at it, even the tricky ones, in a flash. The median time to solve a puzzle was just 0.0386 seconds.
The backtracking detectives, even when they used their best tricks (like "Propagating" clues to eliminate bad options immediately), struggled. The best backtracking setup only solved about 49% of the puzzles within the time limit. When it did solve them, it took longer, and for the hardest puzzles, it simply gave up. The researchers found that Binairo's rules (like "no three in a row") translate very neatly into the language that SAT solvers speak, allowing the computer to see the whole picture instantly.
For Hitori: The Backtracking Detective Takes the Crown
Hitori told a different story. Here, the Backtracking approach, specifically one using Constraint Propagation, was the hero. It solved 100% of the puzzles. The SAT solver, however, hit a wall. It only managed to solve 23.3% of the puzzles before running out of time.
Why did the SAT solver fail at Hitori? The culprit was the "connectivity" rule (the white cells must stay connected). It is very hard to write this rule as a simple logical sentence for a SAT solver. Instead, the SAT solver had to guess a solution, check if the white cells were connected, and if they weren't, it had to say, "Nope, try again," and start over. This "guess-check-repeat" loop became a nightmare. For the larger puzzles, the solver spent 97.4% of its time just checking connectivity and rejecting bad guesses, rather than actually solving the puzzle.
The Power of Propagation
Across both puzzles, the researchers found that Constraint Propagation was the single most powerful tool for the backtracking method. It's like having a detective who, the moment they find a clue, immediately tells everyone else what they can't do. This reduced the number of wrong turns the computer had to take by huge margins. For Binairo, it dropped the number of search steps from thousands to just 83.5 on average. For Hitori, it dropped the steps from 310 to just 18.
However, the paper also warns that "faster" isn't always "better." They tried a "smart" version of propagation that tried to save time by only checking nearby cells. Surprisingly, this was slower! The extra work required to keep track of which cells to check actually wasted more time than just checking everything simply.
The Takeaway
This study teaches us that there is no "magic bullet" for solving logic puzzles. If your puzzle is like Binairo, with rules that fit neatly into a logical sentence, a SAT solver is your best friend. But if your puzzle is like Hitori, with complex rules about how pieces must connect, a smart, step-by-step backtracking detective with good propagation skills is the way to go.
The authors suggest that future work might try to mix these methods—using a backtracking detective to do the heavy lifting and a SAT solver to handle the tricky parts. But for now, the lesson is clear: to tame the search space, you have to understand the beast you are hunting.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.