def partition0(max_range, S):
    K = len(max_range)
return np.array([i for i in itertools.product(*(list(range(i + 1)) for i in
    max_range)) if sum(i) <= S])
Generating a numpy array with all combinations of numbers that sum to less than a given number