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
  • 3 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.
I asked a question just yesterday which caused this new issue. gdb within emacs
I'm new to Neo4j - just started playing with it yesterday evening. I've notice
yesterday I just asked following question. How to customize tableView Section View - iPhone
Seems like just yesterday I had this same problem with Play! v1. After trying
I just publicated yesterday my first android application. I did not tested on android
I am new to RabbitMQ. I just started yesterday. I did few spikes on
I just installed VisualSVN server yesterday at my home computer and I can access
I just start learning to write web services yesterday, kinda fascinating. I created an
I just started working using Google Maps API yesterday, and trying to set up

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.