python3 find a list of all subsets

python3 find a list of all subsets

def PowerSetsBinary(items):
    N = len (items)
     for I in Range (N ** 2): # subset number 
        Combo = []
         for j in Range (N): # used to determine the position of the index j of the binary numbers whether. 1 
            iF (I >> J)% 2 :
                combo.append(items[j])
        print(sum(combo))
        print(combo,"\n")

        
L = [100000,12844.26,11393.83,14819.92,747.04,843,30435.12,3628.48,40856.32,12326.16,20259.01,16360.18,26146.4,4268.8,6403.2,5015.84,41366.51,6819.48,15061.12,31887.67,28590.49,63716.64,9469.35,12749.43,16346.4,100000,23557.22,1067.2,192.1,533.6]
print(round(sum(L),2))
#PowerSetsBinary(L)

 

Guess you like

Origin www.cnblogs.com/alantop/p/12316800.html