# 15 puzzle

The **15-puzzle** (also called **Gem Puzzle**, **Boss Puzzle**, **Game of Fifteen**, **Mystic Square** and many others) is a sliding puzzle that consists of a frame of numbered square tiles in random order with one tile missing. The puzzle also exists in other sizes, particularly the smaller **8-puzzle**. If the size is 3×3 tiles, the puzzle is called the 8-puzzle or 9-puzzle, and if 4×4 tiles, the puzzle is called the 15-puzzle or 16-puzzle named, respectively, for the number of tiles and the number of spaces, the object of the puzzle is to place the tiles in order by making sliding moves that use the empty space.

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*.

## Contents

## Solvability[edit]

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, it is also NP-hard to approximate the fewest slides within an additive constant, but there is a polynomial-time constant-factor approximation.^{[1]}^{[2]} For the 15-puzzle, lengths of optimal solutions range from 0 to 80 single-tile moves (there are 17 configurations requiring 80 moves)^{[3]}^{[4]} or 43 multi-tile moves;^{[5]} 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.^{[5]}

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

The transformations of the fifteen puzzle form a groupoid (not a group, as not all moves can be composed);^{[9]}^{[10]}^{[11]} this groupoid acts on configurations.

## Alternate proof[edit]

In an alternate view of the problem, we can consider the invariant to be the sum of the parity of the number of inversions in the current order of the 15 numbered pieces and the parity of the difference in the row number of the empty square from the row number of the last row. (Let's call it row distance from the last row.) This is an invariant because each column move, when we move a piece within the same column, changes both the parity of the number of inversions (by changing the number of inversions by ±1, ±3) and the parity of the row distance from the last row (changing row distance by ±1); and each row move, when we move a piece within the same row, does not change any of the two parities. Now if we look at the solved state of the puzzle, this sum is even. Hence it is easy to prove by induction that any state of the puzzle for which the above sum is odd cannot be solvable; in particular, if the empty square is in the lower right corner (even anywhere in the last row) then the puzzle is solvable if and only if the number of inversions of the numbered pieces is even.

## History[edit]

The puzzle was "invented" by Noyes Palmer Chapman,^{[12]} a postmaster in Canastota, New York, who is said to have shown friends, as early as 1874, a precursor puzzle consisting of 16 numbered blocks that were to be put together in rows of four, each summing to 34. Copies of the improved Fifteen Puzzle made their way to Syracuse, New York, by way of Noyes' son, Frank, and from there, via sundry connections, to Watch Hill, Rhode Island, and finally to Hartford (Connecticut), where students in the American School for the Deaf started manufacturing the puzzle and, by December 1879, selling them both locally and in Boston, Massachusetts. Shown one of these, Matthias Rice, who ran a fancy woodworking business in Boston, started manufacturing the puzzle sometime in December 1879 and convinced a "Yankee Notions" fancy goods dealer to sell them under the name of "Gem Puzzle"; in late January 1880, Dr. Charles Pevey, a dentist in Worcester, Massachusetts, garnered some attention by offering a cash reward for a solution to the Fifteen Puzzle.^{[12]}

The game became a craze in the U.S. in February 1880, Canada in March, Europe in April, but that craze had dissipated by July. Apparently the puzzle was not introduced to Japan until 1889.^{[citation needed]}

Noyes Chapman had applied for a patent on his "Block Solitaire Puzzle" on February 21, 1880. However, that patent was rejected, likely because it was not sufficiently different from the August 20, 1878 "Puzzle-Blocks" patent (US 207124) granted to Ernest U. Kinsey.^{[12]}

### Sam Loyd[edit]

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'."^{[13]} 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.^{[12]}^{[14]}

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,^{[15]} 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 permutation.

## Miscellaneous[edit]

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*.^{[citation needed]}

Several browser games are inspired of n-puzzle mechanic, e.g., Continuity^{[16]} or Rooms.^{[17]}

## See also[edit]

- Combination puzzles
- Jeu de taquin, an operation on skew Young tableaux similar to the moves of the 15 puzzle
- Mechanical puzzles
- Minus Cube
- Pebble motion problems
- Rubik's Cube
- Sliding puzzle
- Klotski
- Three cups problem

## Notes[edit]

**^**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.**^**Ratner, Daniel; Warmuth, Manfred (1990). "The (n^{2}−1)-puzzle and related relocation problems".*Journal of Symbolic Computation*.**10**(2): 111–137. doi:10.1016/S0747-7171(08)80001-6.**^**Richard E. Korf, Linear-time disk-based implicit graph search,*Journal of the ACM*Volume 55 Issue 6 (December 2008), Article 26, pp. 29-30. "For the 4 x 4 Fifteen Puzzle, there are 17 different states at a depth of 80 moves from an initial state with the blank in the corner, while for the 2 x 8 Fifteen Puzzle there is a unique state at the maximum state of 140 moves from the initial state."**^**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.

:"Gasser found 9 positions, requiring 80 moves...We have now proved that the hardest 15-puzzle positions require, in fact, 80 moves. We have also discovered two previously unknown positions, requiring exactly 80 moves to be solved."- ^
^{a}^{b}"The Fifteen Puzzle can be solved in 43 "moves"". Domain of the Cube Forum **^**"24 puzzle new lower bound: 152". Domain of the Cube Forum**^**"5x5 can be solved in 109 MTM". Domain of the Cube Forum.**^**"m × n puzzle (current state of the art)". Sliding Tile Puzzle Corner.**^**Jim Belk (2008) Puzzles, Groups, and Groupoids, The Everything Seminar**^**The 15-puzzle groupoid (1), Never Ending Books**^**The 15-puzzle groupoid (2), Never Ending Books- ^
^{a}^{b}^{c}^{d}*The 15 Puzzle*, by Jerry Slocum & Dic Sonneveld, 2006. ISBN 1-890980-15-3 **^***Cyclopedia of Puzzles*, p. 235**^**Barry R. Clarke,*Puzzles for Pleasure*, pp.10-12, Cambridge University Press, 1994 ISBN 0-521-46634-2.**^**Korf, Richard E. (2000), "Recent progress in the design and analysis of admissible heuristic functions" (PDF),*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**^**Interview of Pixelshocks, which have developed Continuity game : http://jeuxgratuitsenligne.over-blog.com/-continuity-uses-an-analogy-to-the-n-puzzle**^**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

## References[edit]

- Archer, Aaron F. (1999), "A modern treatment of the 15 puzzle",
*The American Mathematical Monthly*,**106**(9): 793–799, doi:10.2307/2589612, ISSN 0002-9890, MR 1732661 - Johnson, Wm. Woolsey; Story, William E. (1879), "Notes on the "15" Puzzle",
*American Journal of Mathematics*, The Johns Hopkins University Press,**2**(4): 397–404, doi:10.2307/2369492, ISSN 0002-9327, JSTOR 2369492 - Edward Kasner & James Newman (1940) Mathematics and the Imagination, pp 177–80, Simon & Schuster.
- Wilson, Richard M. (1974), "Graph puzzles, homotopy, and the alternating group",
*Journal of Combinatorial Theory, Series B*,**16**: 86–96, doi:10.1016/0095-8956(74)90098-7, ISSN 0095-8956, MR 0332555

## External links[edit]

Wikimedia Commons has media related to .15 puzzle |