Let's say we have a jigsaw puzzle with N pieces. Each piece has 4 sides and can only have one of three fits: a straight fit, a concave fit and convex fit. A side can only fit with another side if both sides are a straight fit or if they are opposites, i.e. one side is concave and the other is convex. Also, the sides on the perimeter can only be straight. How can I determine, without actually putting it together, if it indeed has a solution or not?