Need an Algorithm to solve the Geometric Puzzle

Hi there, I already ask this question on Answer Hub but I don’t see a bright solution, so I go there.
I’m trying to make a geometric puzzle game for kids. I have done all the dragging stuffs. I’m confused on the checking part of the game. After the user has put all the pieces together, how can I check if the user is correct, it means there are many ways to complete 1 shape, like this:

I thought about using anchor point to handle this but this idea same to lame and just working at the unique cases. Here is an image with anchor point (the black asterisk):

And here is when I move the red square to the right, it meets the anchor point but not fit the gray shape.

How can I handle this problem ? Are there any algorithms for it ? Thanks

Are you asking for how to check if the placed parts are “correct”?

Not quite sure how your game works, but I’ll assume that you cannot place a rectangle so that it’s partly outside the game area or overlapping another part. In that case, couldn’t you simply calculate and add together the various areas of the individual parts and compare to the game area?

Example: In your top example. You red square is 2x2=4, your yellow square is 1x2=2, the purple and blue are both 1x1=1.
If you add them together you get 8. You game area is 4x2=8. If 8 == 8 you win.

If you are asking for how to place the squares, couldn’t you use several anchor points per square?

Maybe I missed some essential part of your game here. If not, I hope it helps.

Thanks for your help. The area solution looks good.
But I think the idea to use several anchor points is quite complicated. Example: in my example above, in order to drag and drop the pieces into anywhere in the gray shape, I must create 2 anchors for red square, 4 anchors for yellow, 8 anchors for purple and blue. If I have about 10 pieces, it’s will hard to organize.
I already think about a solution that compare distance between 2 edges of 2 sprites, but I don’t find any tutorial for it.
Do you have another idea ?

Do you want the squares to snap to a “grid”?
You could divide the game are into a grid, by making an array, and saying that an array element represents x times y pixels/units in size. Then you could designate the upper left point of a square as the “main point”, and check where that point is when the user “lets go” of it. If it is within a set grid box, you could check if the necessary nearby grid boxes are free, or if they exist. If they don’t exist the user is placing the square outside the play area etc.

It should be fairly simple to make a “check array” function for each of your basic shapes.

Don’t know if this makes sense. I’m envisioning a game where you drag squares out from a “menu” into a game area.