I have the following Problem: Consider a Vector of Vector, such as
[[p00, p01, p02], [p10, p11], [p20, p21, p22, p23]]
I have to find every possible combination of each element, i.e.
[[p00, p10, p20],
[p00, p10, p21], ...
[p00, p10, p23],
[p00, p11, p20], ... ]
In general I do have a vector<vector< MyClass >> mat
with mat.size() = d
and each combination should be a vector< MyClass > comb1
with comb1.size() = d
.
I have found several threads, such as this solution, where each List inside the mat is the same size. However, using DuckDuckGo I was not able to find a proper solution that works for my case, where each vector can have different sizes. I also need to save the resulting vectors, in an extra matrix or directly link it to what I need.
I also figured out, it is the best way to somehow use a recursion. However, I already fail to see what kind of termination criterion I need, since in the link above, we had a fixed size for each entry of mat
.