You are on page 1of 6

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/36379189

Properties of, and solutions to, Kakuro and related puzzles

Conference Paper · March 2008


Source: OAI

CITATION READS

1 1,904

3 authors, including:

Paul Alun Roach Stephanie Perkins


University of South Wales University of South Wales
54 PUBLICATIONS 693 CITATIONS 45 PUBLICATIONS 283 CITATIONS

SEE PROFILE SEE PROFILE

Some of the authors of this publication are also working on these related projects:

Centenary Doctoral Scholarship - Modelling Ultrasonic Transducers View project

Social Dynamics View project

All content following this page was uploaded by Paul Alun Roach on 15 August 2014.

The user has requested enhancement of the downloaded file.


1

Properties of, and solutions to, Kakuro and


related puzzles
Ryan P Davies, Paul A Roach, and Stephanie Perkins, Faculty of Advanced Technology

 Such puzzles are also called promise-problems (the promise


Abstract— Kakuro is a logic puzzle that has strong being a unique solution) [1]. Many puzzles have reflective or
connections with crosswords. Within an n m grid, a number of rotational symmetry, although this is only to improve the
initially empty cells make up overlapping continuous runs, each visual appearance of the grid. Each white cell is initially
being horizontal or vertical. A total is associated with each of empty. A range of types of logical deduction and reasoning
these runs, and the puzzle is solved by entering digits into the
may be required for the solution of a puzzle, but no
cells so that each run sums to the specified total, and no digit is
repeated in any run. Published puzzles have unique solutions guesswork should be needed [2].
that may be determined through the use of game constraints “Cross Sum” puzzles, as they were then known, first
and the exercising of reasoning and strategy. However, more emerged when New York publisher Dell Magazines
generalised Kakuro and associated cross-sum puzzles are not published such puzzles in 1966. However, huge popularity
well-formed and possess multiple solutions, requiring other came only after the re-branding of “Cross Sums”, which
methods such as search techniques for their solution; further, occurred after the puzzle was imported to Japan in 1980.
combinatorial methods are required for an analysis of the
number of solutions possible.
Improved and renamed ‘Kasan Karuso’ (the Japanese
In this paper, we examine problem size and complexity by pronunciation of the English word "cross" appended to the
investigating the numbers of ways in which the cells of runs Japanese word for "addition") by Japan’s Nikoli Puzzles
might be filled with the available digits. This examination Group, the puzzle was then exported back to the West six
reveals important problem features. We then present three years later following another name change; this time to
different approaches for the automatic solution of Kakuro Kakuro [3]. Today, the popularity of Kakuro in Japan is
puzzles that exploit these problem features. Finally, an analysis reported second only to Sudoku [3].
of the effectiveness and efficiency of each approach is
It is only over the last two or three years that the puzzle
presented, and suggestions for the future direction of work are
offered. has gained wider global popularity, for example being
launched in The Guardian newspaper in the United Kingdom
Index Terms—Enumeration, Binary Integer Programming, on September 14th 2005 [4]. Other UK papers soon
Search, Kakuro. followed.
Related puzzles include “Cross-sum Sudoku” [5], which
I. INTRODUCTION combines the rules of standard Kakuro puzzles with the
constraints of standard Sudoku puzzles, and “Cross
K AKURO puzzles typically consist of an n m grid
containing black and white cells. White cells are initially Products”; where “clue” cells suggest the product of digits
in a run, rather than the sum.
empty and are organised into overlapping continuous runs
that are exclusively either horizontal or vertical. A run-total, At present, little has been published specifically on Kakuro
usually given in a black “clue” cell, is associated with each of and its related puzzles.
these runs, and the puzzle is solved by entering digits
(typically in the range 1,...,9 ) into the white cells such that II. TERMINOLOGY
each run sums to the specified total, and no digit is repeated A Kakuro grid may be termed K, where K has dimension
in any run. Assuming only numbers in the range 1,...,9 are n m , and the cell at row i and column j is termed k i , j . All
used, a run can be between two and nine squares in length cells can be referred to in such a way, regardless of whether
with a total in the range 3,...,45 . they are black “clue” cells or white “available” cells.
Kakuro puzzles have often been likened to a typical Grid K contains a collection of both horizontal and
crossword puzzle, due to the fact that there are “clues” that vertical runs, each individual run being exclusively either
specify correct numerical “words”. Unlike crosswords, horizontal or vertical, the set R. A run is termed rl
Kakuro puzzles more easily transcend language barriers.
( l  1,..., p ) such that rl  R and p is the number of runs.
Most published puzzles consist of an n m grid and are
well formed, meaning that only one unique solution exists. Therefore rl is described as a vector of connected white
squares such that:
Manuscript received Feb 21, 2008.
R. P. Davies, P. A. Roach and S. Perkins are with the Faculty of rl  (ki , js ki , je ) , where ki , j  K ,
Advanced Technology, Department of Computing and Mathematical
Sciences, University of Glamorgan, Pontypridd, Mid Glamorgan, CF37 describes a horizontal run in row i that begins in column js
1DL, United Kingdom (phone: +44 (0)1443 483485; e-mail: rpdavies@ and ends in column je.
glam.ac.uk).
2

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 ( 22) 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 ( 22) 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 ( 22) 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 ( 22) 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 ( 23) 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 ( 22) , 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 ( 22) 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 ( 22) .
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 ( 22) with a cell
k1,3 that is connected to one run in K ( 22) 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 ( 22) grids and augmentations 4. Grid 4 is obtained by augmenting K ( 22) 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

k 2,1 ) then the number of possible arrangements


is: x( x  1)( x  2) 2 . The solving of Kakuro puzzles is a problem known to be NP-
Complete [8]. That is, the solutions to the puzzles are easily
V. Finally, consider k1,3 ≠ k 2, 2 ≠ k 2,1 and k1, 2 ≠ verifiable in non-deterministic polynomial time and the
k 2,1 then the number of possible arrangements solving algorithm used can also be employed to solve all
other NP problems [9].
is: x( x  1)( x  2)( x  3) 3 .
Combining the five sub-cases, the total number of
possible valid arrangements is: IV. AUTOMATING THE SOLUTION OF KAKURO
x( x  1)( x  2)( x 3  6 x 2  14 x  13) . ∎
Several free and commercially available automatic solvers
For example, if numbers in the range 1,...,9 are placed exist. However, they enable the solution only of small, well-
into Grids 1 to 5 of Fig. 2, the numbers of valid formed puzzles (typically less than 1212 ), for which it
possible arrangements for which there are no duplicate would be feasible to determine a solution through exhaustive
digits in any row or any column run are: consideration of all digit combinations (described below).
1. 4104 for K ( 22) (Grid 1, Fig. 2); Where multiple solutions exist, and where puzzle size and
dimensions are very large, it is necessary to adopt more
2. 36,936 for Grid 2, Fig. 2; sophisticated approaches. Three methods implemented by the
3. 28,728 for Grid 3, Fig. 2; authors for the automated solution of Kakuro puzzles are
4. 201,096 for Grid 4, Fig. 2; described here.
5. 179,424 for K ( 23) (Grid 5, Fig. 2).
4

be placed on the decision variables, further affecting how the


i) Exhaustive production of all possible grid arrangements decision variables may be set for the determination of a valid
puzzle solution.
An exhaustive Kakuro solver has been implemented using For an n m grid, this approach requires different types of
the Java programming language. In this approach, the white constraints:
cells in the puzzle are, in turn, assigned every possible integer  Only one value can be assigned to any one cell. In terms
value in the range 1,..., x . A series of constraints is of the decision variables, this means:
9
implemented during each cycle that selects only those results
where there are no duplicates in runs and where the correct A
h 0
i , j ,h 1 1 ≤ i ≤n, 1 ≤ j ≤m
run-totals are met. Of course, well-formed problems should
only have one solution, so only one grid arrangement should  Since no numerical value in the range 1,...,9 can be added
fit the criteria in such cases. This approach is adequate for to a black ‘clue’ cell, it is assigned the value zero. Hence,
smaller grids or when a smaller range of numbers is to be for any black cell k i , j :
used. For example, the puzzle shown in Fig. 1 is solved in
29.828 seconds (and faster implementations are possible).
Ai , j ,0  1
However, exhaustive techniques are very time consuming Ai , j ,h  0 h0
and inefficient for most puzzle grids where very large
 Conversely, white cells should only accept numbers in the
numbers of grids would have to be checked. (If w is the
number of white cells, then xw grids need to be exhaustively range 1,...,9 . Hence, for any white cell k i , j :
considered for x   .) The processing time is not justified. Ai , j ,0  0
 Within each run, the same digit cannot appear more than
ii) A Binary-Integer Programming (BIP) Approach
once. Hence for a run in row i of K that begins in column
js and ends in column je:
This approach involves a three-dimensional array of binary
je
decision variables, Ai , j ,h , where i and j represent the row and
column positions of a cell in K and h represents each digit in
A
j  js
i , j ,h 1 1 ≤ h ≤ 9, 1 ≤ i ≤n

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

cases, a constraint would force ‘floor zero’ to be ‘lit’.  hA


j  js h 1
i , j ,h  tl 1 ≤ i ≤n

9 and for a run in row j of K that begins in column is and


8
1 7 ends in column ie :
6
i ie 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 55 0.00302
cells have been filled. Following puzzle and queue 66 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

View publication stats

You might also like