Given a pair of integers
k, I want to generate all lists of integers of length
n, containing integers between
+k, such that the total of the list is equal to zero. How can I do this in the most performant way?
Naively, I could do something like
but this means I'm generating far more
Tuples than I need, and for relatively small values of
k, this fails with error
I do not need all permutations. Is there a less wasteful way to generate all such lists?