Is there a mathematical way to check if a KenKen (Mathdoku / Calcdoku) puzzle has at most one solution

combinatoricspuzzle

Is there a mathematical way to check if a KenKen (Mathdoku / Calcdoku) puzzle has at most one solution without trying every permutation and then checking if two different permutations both solve the puzzle?

If not, is there a way to generate such a puzzle so that it can only have one solution?

An obvious way to check if there is only one solution would be to solve it and check if there are at least two solutions (e.g. with backtracking algorithms), but with large grids this becomes unfeasible.

From what I've noticed it seems that from one solution you can create another one by swapping columns and/or rows (column and row constraints won't be broken) and hope that the cage constraint isn't broken.
This would take n!^4 operations, with n being the size of the grid (column/row length).

Also checking for symmetry in cage disposition could be a possible approach, even though, from various attempts I made, it seems inconclusive.

Best Answer

I don't have any mathematical proofs or references, but I highly doubt there is an efficient algorithm to do this.

First, solving partially filled Latin squares is known to be NP-complete, and given the close relationship between KenKen and Latin Squares, I therefore highly suspect solving KenKen puzzles is NP-complete. In fact, you could treat every clue cell for the Latin square as its own region with that number as the clue for a KenKen puzzle, so if this is the kind of KenKen p[uzzles where you are allowed to have regions without any clue number, then you can just treat all other cells as their own clue-less region as well.

Second, generating a puzzle with a unique solution is probably as hard as solving solving. For example, I know that many Sudoku-generating algorithms simply either add more and more clues to an empty grid, or subtract more and more clues from a full grid, and use a solver to check for uniqueness. Note that this is brute force and there is nothing what I think you mean by 'mathematical' about this.

Now, you could constrain the regions and/or clues to such an extent that sure, a puzzle with a unique solution can be generated very quickly. In the extreme case, we could use the connection with the Latin squares as mentioned earlier to effectively put down a number in each cell except for one or two. But now of course you get highly uninteresting KenKen puzzles.

Indeed, there is a bit of subjectiveness to your question, as I assume your question is really asking about a method to generate interesting KenKen puzzles with a unique solution, and 'interesting' is hard to define mathematically.

Of course, the really 'interesting' Sudoku puzzles are made by hand, and same goes for KenKen puzzles. If only we could translate the ingenuity of those puzzle creators into an algorithm!