Professional Documents
Culture Documents
net/publication/36379189
CITATION READS
1 1,904
3 authors, including:
Some of the authors of this publication are also working on these related projects:
All content following this page was uploaded by Paul Alun Roach on 15 August 2014.
Lemma
Alternatively: The number of possible arrangements for the placement
rl (kis , j kie , j ) , where k i , j K , of integer values in the range 1,..., x , x in which
describes a vertical run in column j that begins in row is and there are no duplicate digits in any row run or any
ends in row ie. column run for:
A blank Kakuro grid, K, becomes a puzzle state when run 1. a K ( 22) grid (Grid 2, Fig 2) is
totals are added to the black “clue” cells, such that valid x( x 1)( x 2 3x 3) ;
arrangements of digits can be added to runs by the
2. a K ( 22) grid augmented with cell k 3,3 (Grid 2, Fig
deployment of logic alone to obtain a solution, or completed
state. An example is shown in Fig 1. It is possible for a 2) is x 2 ( x 1)( x 2 3x 3) ;
puzzle to have multiple solutions; however, a proper, well- 3. a K ( 22) grid augmented with cell k1,3 (Grid 3, Fig
formed puzzle will have a single unique solution.
2) is x( x 1)( x 2)( x 2 3x 3) ;
4. a K ( 22) grid augmented with cells k1,3 and cell k 3,1
(Grid 4, Fig 2) is x( x 1)( x 2) 2 ( x 2 3x 3) ;
5. a K ( 23) grid (Grid 5, Fig 2) is
x( x 1)( x 2)( x 6 x 14 x 13) .
3 2
Proof
The cases will be considered separately:
1. Elements within runs (k1, 2 , k 2,1 ) , (k 2,1 , k 2, 2 ) ,
Fig. 1. A Puzzle Grid [6] (k1,1 , k 2,1 ) and (k1, 2 , k 2, 2 ) cannot contain equal
A puzzle where every clue is needed in order to obtain a values. However, values in cells k1,1 and k 2, 2 , k1, 2
unique solution may be thought of as irreducible (in a similar and k 2,1 can be the same since they are in distinct
way to the definition of an irreducible Sudoku puzzle [7]). runs. Without loss of generality, consider the
equality or non-equality of cells k1, 2 and k 2,1 . The
III. PROBLEM SIZE
problem is split into two cases. The first case, cell
Kakuro grids can vary in both size and difficulty. Generally,
k 2,1 contains an equal value to cell k1, 2 , therefore
the complexity of a given puzzle cannot alone be judged on
the size of the grid, but instead should be judged on a the number of possible arrangements of the digits is:
combination of grid size, the magnitudes of the run-totals x( x 1)( x 1) . The second case, cell k 2,1 contains a
and the number of empty (white) cells in its initial state. different value to cell k1, 2 . The number of possible
Some runs may be very constrained as to the number of
solutions. For example, a run having a total of 3 can only be arrangements is: x( x 1)( x 2)( x 2) . Combining
satisfied by either (1, 2) or (2, 1). The presence of longer the two cases of K ( 22) , the total number of
runs adds to the problem complexity. A run of length 9 can possible valid arrangements is: x( x 1)( x 2 3x 3) .
only be solved using all of the digits 1,...,9 , but they may be
(1)
ordered in 9! = 362,888 ways. Further, other runs might be 2. Grid 2 is obtained by augmenting K ( 22) with a cell,
solved by using different subsets of the digits 1,...,9 , as well
as by different orderings of those digits. k 3,3 , that is not connected to any run in K ( 22) .
In the following example grids (Fig. 2) there are no run- Therefore, since any of the x digits could be placed
total constraints, so the only requirement is to avoid into k 3,3 , the resulting number of arrangements is
duplications in runs. (1) multiplied by x.
3. Grid 3 is obtained by augmenting K ( 22) with a cell
k1,3 that is connected to one run in K ( 22) so the
value placed in k1,3 would have to take into account
the values placed in cells k1,1 and k 2,1 . Therefore,
since ( x 2 ) digits could be placed into k1,3 , the
resulting number of arrangements is (1) multiplied
by ( x 2 ).
Fig. 2. K ( 22) grids and augmentations 4. Grid 4 is obtained by augmenting K ( 22) with a cell
k1,3 that is connected to run (k1,1 , k1, 2 ) and k 3,1 that
3
is connected to run (k1,1 , k 2,1 ) . Any value placed in These results have been verified, through exhaustive
cell k1,3 would have to take into account the values production of grid arrangements by the implementation
described in Section IV part i).
placed in cells k1,1 and k1, 2 . Similarly, any value
placed in cell k 3,1 would have to take into account When run-totals are added to construct a well-formed
puzzle, only one arrangement of digits will form a valid
the values placed in cells k1,1 and k 2,1 . Therefore,
solution. However, in solving a puzzle (either manually, or
since x 2 digits could be placed in either of these automatically as in Section IV below), it is inevitable that
new cells, the resulting number of arrangements is multiple arrangements of digits in runs must be considered.
(1) multiplied by ( x 2) 2 . To highlight the apparent complexity of this process,
5. Elements within runs (k1,1 , k1, 2 , k1,3 ) , consider the puzzle of Fig. 1. In the uppermost horizontal
run, there are 24 possible combinations of digits that satisfy
(k 2,1 , k 2, 2 , k 2,3 ) , (k1,1 , k 2,1 ) , (k1, 2 , k 2, 2 ) and
the total and non-duplication constraints. Taking that run and
(k1,3 , k 2,3 ) cannot contain equal values. However, the leftmost vertical run together, there are 756 possible
the same values are permitted in cells that are not combinations. Table 1 shows this process continued, with the
horizontally or vertically adjacent to one another number of potentially valid arrangements of digits rising
since they are in distinct runs. Without loss of rapidly, before falling more gradually as the last cells and
generality, consider the equality or non-equality of constraints are taken into account. This behaviour is more
cells k1, 2 and k 2,1 in combination with the equality marked as puzzle complexity increases, and it is this property
of the puzzle that makes it difficult to solve.
or non-equality of both k1,3 and k 2,1 , and k1,3 and
k 2, 2 . The problem is therefore split into five sub- Number of Number of Valid
runs Solutions
cases. 1 24
I. Consider k1, 2 = k 2,1 , k1,3 ≠ k 2, 2 and k1,3 ≠ k 2,1 , 2 756
3 2,160
then the number of possible arrangements is:
4 2,592
x( x 1)( x 2) 2 ( x 3) . 5 1,320
II. Consider k1,3 = k 2, 2 , k1, 2 ≠ k 2,1 and k1,3 ≠ k 2,1 , 6 404
7 216
then the number of possible arrangements is:
8 20
x( x 1)( x 2) 2 ( x 3) . 9 20
III. Consider k1,3 = k 2,1 , k1, 2 ≠ k 2,1 and k1,3 ≠ k 2, 2 , 10 16
11 1
then the number of possible arrangements is: 12 1
x( x 1)( x 2) 3 .
Table 1: The effect of number of runs on number of valid
IV. Consider k1,3 = k 2, 2 and k1, 2 = k 2,1 (so k1,3 ≠ solutions of the puzzle of Fig. 1
the allowed assignment range. Ai , j ,h takes the value one if h and for a run in column j of K that begins in column is
and ends in column ie:
is the digit in cell k i , j , and zero otherwise. A useful
ie
visualisation of this approach might be an n m grid where
each cell contains a ‘tower’ as shown in Fig. 3. For a puzzle
A
i is
i , j ,h 1 1 ≤ h ≤ 9, 1 ≤ j ≤m
into which the digits 1,...,9 are to be placed, each ‘tower’ For each run, rl, the digits must sum to the required run-
contains ten floors, each representing a value that can be total, termed here as tl. Ten decision variables are
assigned to the cell. If, for example, a “9” is placed into associated with each cell but only the one with h value
cell k 4, 4 , the ‘ninth floor’ would become ‘lit’. This matching the digit in the cell is equal to 1. Hence for a
run in row i of K that begins in column js and ends in
corresponds to decision variable A4, 4,9 taking the value one. column je :
The black ‘clue’ cells cannot be assigned a digit so in these je 9
hA
5
2 4
3 i , j ,h tl 1 ≤ j ≤m
3
2 i is h 1
4 1
0 h A valid solution to a puzzle must satisfy all of the above
1 2 3 4 constraints. Xpress-MP, which is a suite of optimisation
j packages, has been employed here to determine the settings
of decision variables that satisfy these constraints for many
Fig 3. A visualisation of the Binary-Integer Programming
different Kakuro puzzles. The package was successfully used
Approach
to solve Kakuro puzzles of dimension less than or equal to
Each cell will be represented in the 3D array by ten decision 5 5 . Larger puzzles exceed the limit of decision variables
variables and so, for example, the cell in the bottom-right allowed within standard versions of the software. The testing
corner of the puzzle will be represented by the variables of this approach for larger puzzles remains as future work.
A4, 4,0 to A4, 4,9 . Of these ten variables, only the variable
iii) Search approach, implemented in Java
where the h value matches the value assigned to the cell will
be set equal to one. The other nine variables associated with A breadth-first search algorithm [10] has been implemented
that particular cell would then equal zero. Constraints may
5
in the Java programming language. In this approach, the on dimension and run-total magnitudes). This issue is
white cells in a puzzle are considered in turn, and partial addressed below. Table 2 presents typical timings for simple
puzzle solutions are added to a queue. However, rather than puzzles (of sizes 3 3 to 6 6 ).
enumerate the full search tree of possible arrangements of
numbers within a given grid, some pruning is performed. Puzzle Dimension Time taken
Only partial solutions which will not exceed run-totals, and (seconds)
which contain no duplication of digits, are added to the 3 3 0.00111
queue. 4 4 0.00198
A state is defined to be a grid in which some or all of the 55 0.00302
cells have been filled. Following puzzle and queue 66 0.00455
initialisation, puzzle states containing potentially valid values
Table 2: Time taken to solve differently sized puzzles
in the first white cell are added to the queue. Subsequently,
the first state in the queue is removed and analysed in order
to find its successor states – that is, possible values for the VI. CONCLUSIONS AND FUTURE WORK
next available white cell are considered. These successor This paper has established a lemma concerning puzzle size
states are appended to the end of the queue. The algorithm is and its relationship to duplication constraints in runs. This
described below: lemma may now be built on, incorporating run-total
constraints to establish theorems concerning the full
ALGORITHM enumeration of Kakuro puzzle grids.
Initialise puzzle information and queue The binary integer programming and Java search
Current-state becomes the initial-state approaches have been demonstrated to be appropriate for the
While available white cells remain, do solution of Kakuro puzzles. Larger-scale optimisation tools
1. Current-cell becomes next available white cell. may now be employed for the solution of larger puzzles.
2. For each value in specified range 1,..., x Similarly, the search approach can be modified to solve
a) Place value in Current-cell. larger puzzles, by the incorporation of state scoring and
b) Check whether resulting state violates any puzzle pre-processing to reduce necessary queue size [10].
horizontal or vertical run-totals or causes This pre-processing is likely to relate to the order in which
duplication in a run. available white cells are chosen to be filled, to take
c) If resulting successor state does not violate advantage of the property that some runs are very much
constraints, append to the end of the queue. more constrained than others as to the number of possible
3. Current state becomes the first state in the queue arrangements of values. This ordering might successfully
Output contents of the queue as valid solution(s). follow the way human solvers complete a puzzle, but it might
also be guided by properties revealed through the application
Although most Kakuro puzzles are well-formed and have of combinatorial techniques.
one, unique solution, this algorithm will output all possible
solutions of a given puzzle. An example solution, for the REFERENCES
puzzle of Fig. 1, is shown in Fig. 4. The program has reliably [1] M. Cadoli and M. Schaerf, “Partial solutions with unique completion”,
solved puzzles with dimensions no larger than 6 6 . Lecture Notes in Computer Science, vol. 4155, pp. 101-105, 2006.
[2] TellMeHowTo.net, “What are the rules of Kakuro”, 2008,
http://www.tellmehowto.net/answer/what_are_the_rules_of_kakuro_1
378.
[3] G. Galanti, “The History of Kakuro”, December 2005,
http://www.conceptispuzzles.com/articles/kakuro/history.htm.
2 3
[4] J. McCurry, “The new grid on the block”, The Guardian, September
14th 2005.
9 5 1 2 [5] X. Yang, Cryptic Kakuro and Cross Sums Sudoku, Exposure
Publishing, August 2006.
5 1 3 1 [6] GamesZoo.org, “A Sample of a Solved Kakuro Puzzle Grid” , 2008,
http://www.gameszoo.org/custom/kakuro/example.jpg.
3 1 4 2 [7] L. Taalman, “Taking Sudoku seriously”, Math Horizons, September
2007, pp. 5-9.
2 1 [8] T. Seta, “The complexities of puzzles, cross sum and their another
solution problems (ASP)”. Senior thesis. Dept of Information Science,
Fig. 4. A Solution State to the puzzle of Fig. 1 University of Tokyo. 2002.
[9] Z. Michalewicz & D. B. Fogel, How to Solve It: Modern Heuristics,
Berlin-Springer, 2000
V. RESULTS [10] E. Rich and K. Knight, Artificial Intelligence, 2nd ed., Singapore:
McGraw-Hill, 1991.
The binary-integer programming approach could not be
tested for puzzles larger than 5 5 due to software
constraints on the number of variables that can be used. A
similar limit was reached with the Java search
implementation, due to the queue length becoming unfeasibly
large for more complex puzzles (where complexity depends