Reputation: 335
I opened my calendar today and it had a puzzle inside. There are six pieces, and I suppose I have to make them into a cube... I tried to solve it and failed hard. So I decided to try to solve it with programming....
I made them into polygons (not sure if that was a good idea), but have no clue how to rotate them and/or check if any shape collides with any other shape.
The shapes are these:
TL;DR: I'm looking for help with checking every possible combination of these shapes to see if they make a cube. In other words, how can I rotate and check polygons (or something else that represents these pieces) for intersection?
Upvotes: 0
Views: 1272
Reputation: 1479
Making them into polygons is not the correct abstraction for this problem.
See, what you have are the 6 sides of the cube, but now you have to figure out how to rotate them. Each polygon has on its edge 12 small squares that are either on or off and must match with the ones next to it. This is a very discrete problem.
The entire cube has 8 (vertices) + 12 * 2 (edges) small cubes on the edges.
Each face, when placed into the cube, will occupy some of those small cubes.
You need to 1) make a mapping that maps the face into the whole cube on the given face, in the given orientation 2) do a search for the configuration where no small cubes are occupied twice.
Upvotes: 2