Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 375687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:31:35+00:00 2026-05-12T14:31:35+00:00

Yesterday I was just playing Jigsaw Puzzle and somehow wondered what would be algorithm

  • 0

Yesterday I was just playing Jigsaw Puzzle and somehow wondered what would be algorithm for solving it.

As human, steps which I followed where:

  1. Separate all pieces in 3 parts, single flat edge, double flat edge and no edge at all.
  2. Separate flat edge pieces as they would be corners of image
  3. Separate single edge pieces as they would form 4 end edges of images
  4. Lastly, pieces with no edges would form internal of the image.
  5. Match the color and image pieces to put pieces together.

I was wondering what would be the efficient algorithm to solve this puzzle efficiently and what datastructure would provide optimum efficient solution.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:31:35+00:00Added an answer on May 12, 2026 at 2:31 pm

    Solving problems like this can be deceptively complicated, especially if no constraints are placed on the size and complexity of the puzzle.

    Here’s my thoughts on an approach to writing a program to solve such a puzzle.

    There are four key pieces of information that you can use individually and together as clues to solving a jigsaw puzzle:

    1. The shape information of each of the pieces (how their edges appear)
    2. The color information of each of the pieces (adjacent pieces will generally have smooth transitions)
    3. The orientation information of each piece (where flat and corner edges may lie)
    4. The overall size and number of pieces provide the general dimensions of the puzzle

    So what kind of information will the program will be supplied – let’s assume that each puzzle piece is an small rectangular image with transparency information used to identify the portion of the puzzle piece that represent non-rectangular edges.

    From this, it is relatively easy to identify the four corner pieces (in a typical jigsaw). These would have exactly two edges that have flat contours (see contour map below).

    Next, I would build information about the shape of each of the four edges of a puzzle piece. This information can be used to build an adjacency matrix indicating which pieces fit together.

    Now we can prune this adjacency matrix to identify just those pieces that have smooth color transitions in their adjacent configuration. This is somewhat tricky because it requires a level of fuzzy matching – since not every pixel-to-pixel boundary will necessarily have a smooth color transition.

    Using the four corner pieces originally identified, we should now be able to reconstruct the dimensions and positions of all of the pieces in the puzzle.

    A convenient data structure for representing edge shapes may be a contour map – essentially a set of integers representing the incremental deltas in distance from the opposing side of the image to the last non-transparent pixel in each of the four sides of the puzzle piece. Pieces that match should have mirror-image contour maps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started playing about with emacs yesterday for a project I'm working on.
So I just started my first rails project yesterday. I had two many-to-many (has_and_belongs_to_many)
Yesterday I was having a heated debate with a coworker on what would be
Yesterday I thought it would be nice to implement my own Trigger in a
Good morning friendly Flashers ;) So I've been trying since yesterday to just load
I'm assuming my lack of knowledge (I just started learning Flex yesterday, hah!) is
The graphic designer created a camtasia video yesterday and im just trying to upload
Just upgraded my xcode to the latest SDK which has the iOS 4.1 SDK.
I got to try an exercise 1 of notepad application just yesterday and passed
I have a git branch (called v4), that was made from master just yesterday.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.