I want a function in Python that generates all permutations of a possible array, where the unique outputs have the following form and constraints:
3 rows, N columns (let's say 63)
Each column is all 0s except one element is either 1 or -1
each row sums to 0, 1 or -1
I know of the itertools and combinations/products modules.
I could use "products" for arrangements of the 6 possible columns, 1: (1 0 0). .... 6: (0 0 -1), but the row sum constraint wouldn't be satisfied.
Plus starting with all possible combinations/products and filtering out the unwanted means starting with an excessively large set. It would be better if the initial set followed the rules to begin with.