标签:gif pow sbin src python TE ssi div pos
也称为求一个集合的所有的子集
采用二进制方法:
def PowerSetsBinary(items): #generate all combination of N items N = len(items) #enumerate the 2**N possible combinations for i in range(2**N): combo = [] for j in range(N): #test jth bit of integer i if(i >> j ) % 2 == 1: combo.append(items[j]) yield combo for i in PowerSetsBinary(‘123‘): print(i) ‘‘‘ [] [‘1‘] [‘2‘] [‘1‘, ‘2‘] [‘3‘] [‘1‘, ‘3‘] [‘2‘, ‘3‘] [‘1‘, ‘2‘, ‘3‘] ‘‘‘
摘自:
https://blog.csdn.net/tszw1007/article/details/77871133
End
标签:gif pow sbin src python TE ssi div pos
原文地址:https://www.cnblogs.com/Neeo/p/9205439.html