Play the classic sliding tile puzzle in 3x3, 4x4 and 5x5 frames. Every shuffle is solvable, and the 3x3 frame can show the first step of a shortest solution.
Puzzle -
Moves 0
Time 0:00
In place 0
Best on this size
Fewest moves -
Fastest time -
Click or tap a tile to slide it into the gap. A tile in the same row or column as the gap slides the whole run together, and that counts as one move. With the keyboard, Tab to a tile and press Enter or Space, or use the arrow keys: each arrow is the direction a tile travels, so Left slides the tile on the right side of the gap one step left. The timer starts at your first move.
Exactly half of all arrangements of the tiles can never be solved, so a naive random shuffle would hand you an impossible puzzle half the time. Sliding a tile never changes the parity of a simple count (inversions: pairs of tiles that are out of order), so only half of all boards are reachable from the solved one. Each shuffle here is a random permutation that is checked against that rule and fixed with a single swap when it fails, so it is always solvable and never already solved. The same seed always builds the same board, and the page address carries it, so you can send someone the exact puzzle.
As-is, no warranty. These apps are free under their listed license and run entirely in your browser. Use at your own risk — don't blame me if your PC catches fire, your dog runs away, or the math turns out wrong. Verify anything that actually matters. None of this is professional financial, medical, legal, or engineering advice.
Put the tiles in order, 1 up to the last number, with the empty gap in the bottom-right corner. Click or tap a tile to slide it into the gap. A tile that shares a row or column with the gap slides the whole run of tiles between them in one go, and that counts as a single move.
With the keyboard, Tab to a tile and press Enter or Space, or use the arrow keys. Each arrow is the direction a tile travels: Left slides the tile on the right side of the gap one step left, Up slides the tile below the gap one step up, and so on. Tiles are labelled for screen readers with their row, column and whether they can move, and each slide is announced with where the tile landed and how many tiles are in place.
Pick a frame size: 3x3 has 8 tiles, 4x4 has 15 and 5x5 has 24. New puzzle shuffles again, Restart puts the current puzzle back to where it began. The timer starts at your first move and pauses while the tab is hidden. The page address carries the size and a seed, so sending the link sends the exact same puzzle. Tile colours follow the numbers, from sky blue for tile 1 through green and amber to rose for the last tile, so a solved board is a smooth rainbow and a mixed-up board looks mixed up. The number is printed on every tile as well. A tile that is already home gets a tick in its corner and a ring, and the “In place” counter tracks them. A hint draws a bright ring and a star on the tile to slide.
Take the 3x3 frame. There are 9! = 362,880 ways to arrange eight tiles and a gap, and exactly half of them, 181,440, can ever be solved. The other half cannot, however long you slide.
The reason is a count that sliding cannot change. Read the tiles in order, left to right and top to bottom, skipping the gap, and count the inversions: pairs of tiles where the bigger number comes first. The solved board has none.
On an odd width (3x3, 5x5) n - 1 is even, so the inversion count stays even forever, and a board is solvable exactly when its count is even. On an even width (2x2, 4x4) every vertical slide flips the parity of the count and also moves the gap one row, so the sum of the inversion count and the gap’s row (counted from the bottom, starting at 1) stays odd. A board is solvable exactly when that sum is odd. Any board that fails the check can never reach the solved one.
Swapping any two tiles flips the parity, which pairs every impossible board with a possible one, so exactly half of all boards pass. The famous 15 puzzle with only the 14 and 15 swapped fails the check, and the tests confirm it.
Checking is the easy half. The harder half is that every board that passes really is solvable. For 3x3 the test suite proves it the blunt way: a breadth-first search from the solved board reaches exactly 181,440 boards, and the parity rule agrees with that search on all 362,880 arrangements, with no exceptions. The same search on the 2x2 frame reaches 12 of 24. For 4x4 and 5x5 the search is out of reach, so the tests instead check that no legal slide ever breaks the invariant, over thousands of slides at each size. That every passing board is reachable on those sizes is the classical parity result, not something this page re-proves.
For scale, 4x4 has 16! = 20,922,789,888,000 arrangements, so 10,461,394,944,000 of them (about 10.5 trillion) are solvable. 5x5 has 25! arrangements and about 7.8 x 10^24 solvable ones.
A naive shuffle that drops the tiles at random produces an impossible board half the time. This one builds a random permutation, runs the parity check, and if it fails swaps the first two tiles, which flips the parity. Because a swap pairs impossible boards with possible ones one to one, every solvable board is equally likely, and the tests check that on the 2x2 frame, where each of the 11 non-solved boards turns up about equally often. A shuffle that lands exactly on the solved board is thrown away and drawn again, so you never start finished.
The shuffle takes a random number function as an input. The page seeds it from the browser’s secure random source, and the same seed always rebuilds the same board, which is how the shareable link works.
On 3x3 the hint button runs a breadth-first search outward from the solved board once, recording how many slides each of the 181,440 reachable boards is from solved. The hint is then a neighbouring board that is one slide closer, which is the first step of a shortest solution. The search takes a moment the first time (the test allows up to three seconds) and the table is reused after that. The hardest 3x3 boards need 31 slides, and only two boards need that many. Tests follow the hint from 40 shuffled boards and check that each reaches solved in exactly the shortest possible number of slides.
Hint slides are counted one tile at a time, while the move counter counts each click once even when a run of tiles slides, so a hint’s “slides remaining” can be higher than the moves you end up using.
After you solve a puzzle without using a hint, the page records your fewest moves and your fastest time for that frame size, and keeps them if they beat the previous best. Only wins count, a solve that used a hint never sets a best, and restarting a puzzle clears its counters.
Nothing is uploaded and there is no account. Your best results are saved in your browser’s local storage as small whole numbers inside a small JSON object, under one key, for each size. Clearing site data removes them. The page address holds the frame size and puzzle seed so a link reproduces the puzzle.
Everything runs locally in your browser.
For informational purposes only. Not financial, medical, or legal advice. You are solely responsible for how you use these tools.