Aug-15-2020, 07:34 PM
(This post was last modified: Aug-15-2020, 07:36 PM by Gribouillis.)
One could have better named the parameters as
That is the meaning of this sum of two lists. Of course there is a special case when the list of candidates is empty. In this case, there is only one subset, the list of chosen items, and the function returns a list containing this single subset.
def subsetsRecur(self, chosen, candidates): ...This function returns the list of all subsets containing all the chosen items plus some of the candidates. This list will be the sum of two lists: the list of all subsets containing all the chosen items plus some of the candidates but the first candidate, and the list of all subsets containing all the chosen items and the first candidate plus some of the remaining candidates.
That is the meaning of this sum of two lists. Of course there is a special case when the list of candidates is empty. In this case, there is only one subset, the list of chosen items, and the function returns a list containing this single subset.