The situation is as follows:
- There are N arrays.
- Each array (0..N-1) stores (x, y) tuples (Cartesian coordinates)
- The length of each array may be different.
I want to extract a subset of the coordinate combinations that make up a complete retouch of size N. In other words; all Cartesian coordinates are adjacent to each other.
Example:
findRectangles({ {*(1,1), (3,5), (6,9)}, {(9,4), *(2,2), (5,5)}, {(5,1)}, {*(1,2), (3,6)}, {*(2,1), (3,3)} })
gives the following:
[(1,1),(1,2),(2,1),(2,2)], ..., ...(other solutions)...
There are no two points from the same set.
At first, I simply calculated the Cartesian product, but it quickly becomes impracticable (my use case currently has 18 arrays of points, each of which contains about 10 different coordinates).