#68 Sliding Tile Puzzle

This classic puzzle relies on a 4 × 4 board with 15 numbered tiles and one free space. The objective is to slide the tiles until the numbers are in the correct order, going left to right and top to bottom. Tiles can only slide; you’re not allowed to directly pick them up and rearrange them. Some versions of this puzzle toy feature scrambled images that form a complete picture once solved.

More information about sliding tile puzzles can be found at https://en.wikipedia.org/wiki/Sliding_puzzle.

The Program in Action

When you run slidingtilepuzzle.py, the output will look like this:

Sliding Tile Puzzle, by Al Sweigart ...

Get The Big Book of Small Python Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.