Suppose there is a matrix:
Next, I take an arbitrary element from each row of the matrix, since the matrix has m rows in total, I end up with m elements.
After that, I arrange these elements together to form a tuple according to the row number from small to large, that is
Obviously, there are 2^m such tuples in total. For example, when m=2, we will have 4 tuples, which are:
So, how can I program to generate these 2^m tuples quickly(In python)? Which algorithm should I use?
Note:
Input: An m×2 matrix
Output: 2^m tuples