15 puzzle

From Wikipedia, the free encyclopedia
  (Redirected from 15-puzzle)
Jump to: navigation, search
A solved 15-puzzle


The n-puzzle is a classical problem for modelling algorithms involving heuristics. Commonly used heuristics for this problem include counting the number of misplaced tiles and finding the sum of the taxicab distances between each block and its position in the goal configuration. Note that both are admissible, i.e., they never overestimate the number of moves left, which ensures optimality for certain search algorithms such as A*.


Johnson & Story (1879) used a parity argument to show that half of the starting positions for the n-puzzle are impossible to resolve, no matter how many moves are made. This is done by considering a function of the tile configuration that is invariant under any valid move, and then using this to partition the space of all possible labeled states into two equivalence classes of reachable and unreachable states.

The invariant is the parity of the permutation of all 16 squares plus the parity of the taxicab distance (number of rows plus number of columns) of the empty square from the lower right corner. This is an invariant because each move changes both the parity of the permutation and the parity of the taxicab distance. In particular if the empty square is in the lower right corner then the puzzle is solvable if and only if the permutation of the remaining pieces is even.

Johnson & Story (1879) also showed that the converse holds on boards of size m×n provided m and n are both at least 2: all even permutations are solvable. This is straightforward but a little messy to prove by induction on m and n starting with m=n=2. Archer (1999) gave another proof, based on defining equivalence classes via a hamiltonian path.

Wilson (1974) studied the analogue of the 15 puzzle on arbitrary finite connected and non-separable graphs. (A graph is called separable if removing a vertex increases the number of components.) He showed that, except for polygons, and one exceptional graph on 7 vertices, it is possible to obtain all permutations unless the graph is bipartite, in which case exactly the even permutations can be obtained. The exceptional graph is a regular hexagon with one diagonal and a vertex at the center added; only 1/6 of its permutations can be obtained.

For larger versions of the n-puzzle, finding a solution is easy, but the problem of finding the shortest solution is NP-hard.[1][2] For the 15-puzzle, lengths of optimal solutions range from 0 to 80 single-tile moves[3] or 43 multi-tile moves;[4] the 8-puzzle always can be solved in no more than 31 single-tile moves or 24 multi-tile moves (integer sequence A087725). The multi-tile metric counts subsequent moves of the empty tile in the same direction as one.[4]

The number of possible positions of the 24-puzzle is 25!/2 ≈ 7.76×1024 which is too many to calculate God's number. In 2011, a lower bound of 152 single-tile moves had been established;[5] current established upper bound is 208 single-tile moves or 109 multi-tile moves.[6][7]

The symmetries of the fifteen puzzle form a groupoid (not a group, as not all moves can be composed);[8][9] this groupoid acts on configurations.


Sam Loyd's unsolvable 15-puzzle, with tiles 14 and 15 exchanged. This puzzle is provably not solvable because moving it to the solved state would require a change of the invariant.
U.S. Political cartoon about finding a Republican presidential candidate in 1880




Sam Loyd[edit]

Sam Loyd's 1914 illustration

Sam Loyd claimed from 1891 until his death in 1911 that he invented the puzzle, for example writing in the Cyclopedia of Puzzles (published 1914): "The older inhabitants of Puzzleland will remember how in the early seventies I drove the entire world crazy over a little box of movable pieces which became known as the '14-15 Puzzle'."[11] However, Loyd had nothing to do with the invention or initial popularity of the puzzle, and in any case the craze was in 1880, not the early 1870s. Loyd's first article about the puzzle was published in 1886 and it was not until 1891 that he first claimed to have been the inventor.[10][12]

Some later interest was fuelled by Loyd offering a $1,000 prize for anyone who could provide a solution for achieving a particular combination specified by Loyd, namely reversing the 14 and 15.[13] This was impossible, as had been shown over a decade earlier by Johnson & Story (1879), as it required a transformation from an even to an odd combination.


The Minus Cube, manufactured in the USSR, is a 3D puzzle with similar operations to the 15-puzzle.

Bobby Fischer was an expert at solving the 15-Puzzle. He had been timed to be able to solve it within 25 seconds; Fischer demonstrated this on November 8, 1972 on The Tonight Show Starring Johnny Carson.

Several browser games are inspired of n-puzzle mechanic, e.g. Continuity[14] or Rooms.[15]

See also[edit]


  1. ^ Daniel Ratner, Manfred K. Warmuth. Finding a Shortest Solution for the N × N Extension of the 15-PUZZLE Is Intractable. National Conference on Artificial Intelligence, 1986.
  2. ^ Ratner, Daniel; Warmuth, Manfred (1990). "The (n2−1)-puzzle and related relocation problems". Journal of Symbolic Computation 10 (2): 111–137. doi:10.1016/S0747-7171(08)80001-6. 
  3. ^ A. Brüngger, A. Marzetta, K. Fukuda and J. Nievergelt, The parallel search bench ZRAM and its applications, Annals of Operations Research 90 (1999), pp. 45–63.
  4. ^ a b "The Fifteen Puzzle can be solved in 43 "moves"". Domain of the Cube Forum
  5. ^ "24 puzzle new lower bound: 152". Domain of the Cube Forum
  6. ^ "5x5 can be solved in 109 MTM". Domain of the Cube Forum
  7. ^ "m × n puzzle (current state of the art)". Sliding Tile Puzzle Corner
  8. ^ The 15-puzzle groupoid (1), Never Ending Books
  9. ^ The 15-puzzle groupoid (2), Never Ending Books
  10. ^ a b c d The 15 Puzzle, by Jerry Slocum & Dic Sonneveld, 2006. ISBN 1-890980-15-3
  11. ^ Cyclopedia of Puzzles, p. 235
  12. ^ Barry R. Clarke, Puzzles for Pleasure, pp.10-12, Cambridge University Press, 1994 ISBN 0-521-46634-2.
  13. ^ Korf, Richard E. (2000), "Recent progress in the design and analysis of admissible heuristic functions", Recent Progress in the Design and Analysis of Admissible Heuristic Functions, SARA 2000. Abstraction, reformulation, and approximation: 4th international symposium, Texas, USA. LNCS 1864 1864, Springer, pp. 45–55, doi:10.1007/3-540-44914-0_3, ISBN 978-3-540-67839-7, retrieved 2010-04-26 
  14. ^ Interview of Pixelshocks, which have developed Continuity game : http://jeuxgratuitsenligne.over-blog.com/-continuity-uses-an-analogy-to-the-n-puzzle
  15. ^ Interview of Kim Jongwa, which has developed Rooms : http://jeuxgratuitsenligne.over-blog.com/kim-jonghwa-that-night-i-came-up-with-the-mechanic-of-rooms


External links[edit]