Categories
Mastering Development

Find all SUBSETS of a 1D array that have a specified number of UNIQUE elements (n) AND a specified sum (s)

Consider a 1D numpy array and two constants as shown: import numpy as np arr = np.arange(60) n = 5 s = 120 arr is always of the form [0,1,2,3,4, … 59,60] for example. QUESTION: From a 1D array (arr), I need to find all subsets exactly n UNIQUE elements that have a specified sum […]