Is there a more efficient way to calculate the power set of an array?
问题 This is my current implementation using bits: Function Array_PowerSet(Self) Array_PowerSet = Array() PowerSetUpperBound = -1 For Combination = 1 To 2 ^ (UBound(Self) - LBound(Self)) ' I don't want the null set Subset = Array() SubsetUpperBound = -1 For NthBit = 0 To Int(WorksheetFunction.Log(Combination, 2)) If Combination And 2 ^ NthBit Then SubsetUpperBound = SubsetUpperBound + 1 ReDim Preserve Self(0 To SubsetUpperBound) Subset(SubsetUpperBound) = Self(NthBit) End If Next