# https://github.com/vsoch/puzzles
from puzzles.models import PhotoPuzzle
puzzle = PhotoPuzzle("avocado-halves.jpeg")
# Show the original image
fig = puzzle.get_image_figure()
# Metrics about the puzzle calculated based on minimum piece size we requested
puzzle.metrics()
Image file : avocado-halves.jpeg Minimum piece size : 30 Width : 640 Height : 360 Number pieces : 252
# Plot the original pieces
fig = puzzle.get_puzzle_figure()
# Shuffle the puzzle and show it (TODO, show in place first)
puzzle.shuffle()
# Now show the puzzle broken into pieces!
puzfig = puzzle.get_puzzle_figure()
%%time
# Solve the puzzle
puzzle.solve()
CPU times: user 22.4 s, sys: 52.3 ms, total: 22.5 s Wall time: 22.3 s
solved_fig = puzzle.get_solved_figure()