13
SOLVING THE KAKURO PUZZLE Andreea Erciulescu Department of Mathematics, Colorado State University, Fort Collins (Mentor: A. Hulpke)

SOLVING THE KAKURO PUZZLE

  • Upload
    dorjan

  • View
    168

  • Download
    6

Embed Size (px)

DESCRIPTION

SOLVING THE KAKURO PUZZLE. Andreea Erciulescu Department of Mathematics, Colorado State University, Fort Collins (Mentor: A. Hulpke). Abstract. - PowerPoint PPT Presentation

Citation preview

Page 1: SOLVING THE KAKURO PUZZLE

SOLVING THE KAKURO PUZZLE

Andreea ErciulescuDepartment of Mathematics,

Colorado State University, Fort Collins (Mentor: A. Hulpke)

Page 2: SOLVING THE KAKURO PUZZLE

Abstract

Kakuro puzzles are NP-complete ("Non-deterministic Polynomial time"). Although brute-force guessing is a possible way to solve them, a better weapon is the understanding of the various combinatorial forms that entries can take for various pairings of clues and entry lengths. In this presentation I will introduce you to one approach towards completing an algorithm to solve Kakuro without guessing.

Page 3: SOLVING THE KAKURO PUZZLE

IntroductionPuzzle's Definition

• is a kind of logic puzzle that is often referred to as amathematical transliteration of the crossword• is given on a grid of black and white cells• the digits 1 to 9 must be filled into all the white cells so that theysatisfy the clues given in some of the black cells • the clues specify the sum of the numbers in the row of successivewhite cells to the right or the column of successive white cells below• no row or column of successive white cells can have a digitrepeated

These puzzles are regular features in most, if not all, math-andlogic puzzle publications in the United States. The popularity of Kakuroin Japan is immense, second only to Sudoku.

You can try out some of these puzzles on the following website: http://www.kakuropuzzle.com

Page 4: SOLVING THE KAKURO PUZZLE

A 4 x 4 example

Page 5: SOLVING THE KAKURO PUZZLE

Methods

• We consider this puzzle a linear problem with variable entries and we solve it over Z

• Smith Normal Form and Lattice Reduction • Combinatorial search

Page 6: SOLVING THE KAKURO PUZZLE

Compute the integer solutions Let the matrix of equations be N, defined as follows: N is a n_row x n_col matrix with entries in {0,1}, where n_rowrepresents the number of equations and n_col represents the numberof unknown variables.

Page 7: SOLVING THE KAKURO PUZZLE

Compute the integer solutions Smith Normal Form

• X = the vector of unknown variables (the solution) in the range 1..9• B = the matrix whose entries are the clues from the black cells, in

the puzzle B=(4,7,6,4,7,6)T

• Need to solve the system Nx=B over the Z-module.• By Smith Normal Form, there are invertible matrices P and Q over

the Z-module such that PNQ=M, where M is in Smith Normal Form.• From the system x=QY and MY=P-1B we have the solution to the

inhomogeneous equation and the solution to the homogeneous equation MY= 0.

• However, the entries are possibly large. For this, we implement Lattice Reduction to find the small integer solutions.

Page 8: SOLVING THE KAKURO PUZZLE

Find the small integer solutions• We use Lattice Reduction on the set formed with both the

homogeneous and the inhomogeneous solutions and as solution get the rows of

and the resulting set of vectors spans the same initial space.

Page 9: SOLVING THE KAKURO PUZZLE

Find the small integer solutions• Now we have the homogeneous solutions and the partial one,

which satisfies the linear system, given by the rows of the matrix

• Since most of the times it is not a solution for the puzzle, we need to proceed to the next step.

Page 10: SOLVING THE KAKURO PUZZLE

Combinatorial Search • Consider all combinations of partial + ∑icihi , where hi are the

homogeneous solutions and ci are small integers that would give small entries in the solution

• Look only for the solutions that satisfy the puzzle ( numbers between 1 and 9 and no duplicates on the same column and same row)

• A possible solution is a linear combination of the reduced basis vectors

• Use backtracking for examining feasible solutions, by systematically eliminating infeasible solutions

Page 11: SOLVING THE KAKURO PUZZLE

Combinatorial Search• We first detect the vectors hi that have few nonzero entries

corresponding to the entries in the particular solution that need to be changed. For these, we test the coefficients ci and prune the tree whenever the choice determines the entry in the solution.

• Observe that lll[4]-lll[3]-lll[2] = [1,3,1,4,2,3,2,1] is the solution to the puzzle.

Page 12: SOLVING THE KAKURO PUZZLE

Future Directions and Conclusions• Solving a Kakuro puzzle is a NP problem. The complexity class NP-

complete (standing for Nondeterministic Polynomial time) is often found in the computational complexity theory. For these problems, one can quickly verify a solution, whenever it is given. However, there is no efficient way to think about a solution in the first place. Solving these problems requires computer algorithms and a large amount of time.

• We have tested puzzles up to the size 25x35 and the algorithm gives the right solution.

• We are looking at a better way to enter the information from the puzzle. • We would like to eliminate the infeasible solutions earlier.• We would like to know what would be the exact range of coefficients that

gives the solution.

Page 13: SOLVING THE KAKURO PUZZLE

Bibliography• Morandi, Patrick, The Smith Normal Form of a Matrix , 17 February,

2005 • Lenstra, Lenstra, Lovasz L., Factoring Polynomials with Rational

Coefficients,1982

Thank you!